csv

Error inserting data into mysql

I am trying to insert data from a csv file into mysql using BigDump. It stops on line 2, with the error: "Query: INSERT INTO location VALUES (1,"O1","","","",0.0000,0.0000,, ); MySQL: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '...

Issues converting csv to xls in Java? Only core Java experience needed - question not related to import.

Hey everyone, First of all, I understand that it's unusual that I want to up-convert like this, but please bear with me. We get these csv files via website export and we have no options to get it in any other form. Now, onto the question: I have this old code that will do this process for me. It basically reads each line, then picks o...

append content of one csv file to another using python

I have 2 csv files: output.csv output1.csv output.csv has a 5 columns of titles. output1.csv has about 40 columns of different types of data. I need to append all the content of output1.csv to output.csv. How can I do this? could somebody please give me a hint on how to go about it ??? i have the following code : reader=csv.DictRe...

to remove specific rows in a csv file using python...

i want ro remove specific lines from the following csv file : "Title.XP PoseRank" 1VDV-constatomGlu-final-NoGluWat. 1VDV-constatomGlu-final-NoGluWat. P6470-Usha.1 P6470-Usha.2 P6470-Usha.3 P6470-Usha.4 P6470-Usha.5 P6515-Usha.1 P6515-Usha.2 P6517.1 P6517.2 P6517.3 P6517.4 P6517.5 P6553-Usha.1 P6553-Usha.2...

to add column values in a specific manner in a csv file using python

hi, i have a csv file similar to the following : title title2 h1 h2 h3 ... l1.1 l1 1 1 0 l1.2 l1 0 1 0 l1.3 l1 1 0 1 l2.1 l2 0 0 1 l2.2 l2 1 0 1 l3.1 l3 0 1 1 l3.2 l3 1 1 0 l3.3 l3 1 1 0 l3.4 l3 1 1 0 i want to be ab...

Print elements of a list to a .csv file

I am reading in a csv file and dealing with each line as a list. At the end, I'd like to reprint to a .csv file, but the lines aren't necessarily even. I obviously cannot just go "print row", since this will print it as a list. How can I print it in .csv format? ...

CSV Import with Validation

I have a need to import a number of CSV files into corresponding tables in SQL. I am trying to write a stored procedure that will import any of these CSV files, using a number of parameters to set things like file name, destination name etc. Simple so far. The problem comes because of the structure of this DB. Each data table has a numb...

CSV to MYSQL parse issue

I am trying to parse a .csv file into a mysql database, and it's not fun. Some rows look like this: "Value", Value, "Value3", ,"Value,Value" And some look like this: Value, Value, , Value, , Value This preg_split worked well except for fields that were empty: foreach ($row as $item) { $item = preg_split( "/[,]*\\\"([^\\\"]+)\\...

Switching files to read from in python's .csv reader

I am reading a csv file several times, but cutting its size every time I go through it. So, once I've reached the bottom, I am writing a new csv file which is, say, the bottom half of the .csv file. I then wish to change the csv reader to use this new file instead, but it doesn't seem to be working... Here's what I've done. ...

Trouble Escaping Apostrophe in PHP CSV Upload with fgetcsv()

Hello, I am uploading email addresses from a CSV file, via fgetcsv(), into a MySQL database. The problem that I am running into is that I cannot escape email addresses containing an apostrophe (or single quote). So, O'[email protected] will not become O\'[email protected] I know that this is supposed to happen, however I have been unable to f...

MySQL import CSV data - ignore some csv columns

Hi guys, I have a couple of CSV files I want to load into my database, but the CSV file contains many many more columns than in my database. How do I import only selected columns from the CSV file into my database? For arguments sake, let's say the CSV contains a header row with the column titles A to Z, and then two million rows with ...

storing the output of a cursor object in csv format

i've accessed a database and have the result in a cursor object. but i couldn't save it :( cur_deviceauth.execute('select * from device_auth') for row in cur_deviceauth: print row writer = csv.writer(open("out.csv", "w")) writer.writerows(cur_deviceauth) i don't get an error msg and i couldn't write it. how do i make it?...

Transforming XML to CSV - details

Hi all, I have some trouble with the correct formulation of a transform. I'm generating CSV files. I can easily generate the following csv: "version","","stuff", "version1version2","annotation1annotation2","yadda", However, I would like for the different instances of subfields to be comma-separated within their string, as fo...

How do i parse columns in a CSV File in Ruby and store it as an array

lets say we have the following csv file: Date,Av,Sec,128,440,1024,Mixed,,rule,sn,version 6/30/2010,3.40,343,352.0,1245.8,3471.1,650.7,Mbps,on,s-2.8.6-38,4.9.1-229,,vs. 342,-0.26%,-0.91%,1.51%,-0.97% 6/24/2010,3.40,342,352.9,1257.2,3419.5,657.1,Mbps,on,s-2.8.6-38,4.9.1-229,,vs. 341,0.23%,0.50%,-1.34%,0.67% 6/17/2010,3.40,341,352.1,1251....

How do I insert data at the top of a CSV file?

How can I go back to the very beginning of a csv file and add rows? (I'm printing to a CSV file from C using fprintf(). At the end of printing thousands of rows (5 columns) of data, I would like to go back to the top of the file and insert some dynamic header data (based on how things went printing everything). ) Thank You. ...

Import - csv to activerecord

I'm writing an import routine that will allow a user to upload a CSV file to load their database. Each row of the CSV corresponds to a model. I'm using FasterCSV to read the file and split the data into individual models, which is working great. I'm just having trouble deciding on the best approach to handle errors. Right now I have t...

Automatically generate a locale csv file for Excel in C++

I want to generate a csv file containing numbers and I want Excel to read that file automatically. However, Excel uses a different csv format depending on the locale settings. For example: English: Text separator: , Decimal separator: . Spanish: Text separator: ; Decimal separator: , Is it possible to automatically detect thos...

jQuery CSV plugin won't split rows into arrays-of-arrays

I am trying to use the jquery "CSV" plugin, as documented here: http://code.google.com/p/js-tables/wiki/CSV According to the documentation: // Convert CSV data into array of arrays jQuery.csv()("1,2,3\n4,5,6\n7,8,9\n"); // = [ [1,2,3], [4,5,6], [7,8,9] ] But when I attempt to do something similar, it just seems to treat the "\n" as a...

HowTo get a Map from a csv string

Hi, I'm fairly new to Scala, but I'm doing my exercises now. I have a string like "A>Augsburg;B>Berlin". What I want at the end is a map val mymap = Map("A"->"Augsburg", "B"->"Berlin") What I did is: val st = locations.split(";").map(dynamicListExtract _) with the function private def dynamicListExtract(input: String) = { if (inp...

Java string comparisions/quotations

Hi, My problem is the comparision of two objects and the strings that they return (accessed through getters). Object one parses a csv file for dates and when printed out through exampleObject.getDateTime() returns the string: "2010-03-26-10-54-06.471000" Object two has its dateTime string set by the user. When I set the dateTime on o...