csv

Import Data From CSV

Ok, this started out as a pretty simple task to import a customers data into our database. The script below loads all the data into memory and then allow manipulation after. string ConString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\"" + FileLoc + "\"; Extended Properties=\"text;HDR=Yes;FMT=Delimited(,)\""; using (OleDbConnectio...

How to efficiently output dictionary as csv file using Python's csv module? Out of memory error.

I am trying to serialize a list of dictionaries to a csv text file using Python's CSV module. My list has about 13,000 elements, each is a dictionary with ~100 keys consisting of simple text and numbers. My function "dictlist2file" simply calls DictWriter to serialize this, but I am getting out of memory errors. My function is: def ...

csv producing diff symbol

header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Content-Length: " . strlen($contents)); // Output to browser with appropriate mime type, you choose ;) header("Content-type: text/x-csv"); header("Content-type: text/csv"); header("Content-type: application/csv"); header("Content-Disp...

mysql & INTO OUTFILE - escape or replace new lines in data

Hi, I have the following sql statement to out put a sql table to a csv file. Some data found in the column 'content' includes new line charactors which is causing issues, is there a way to replace all \n with 's? SELECT id, title, content INTO OUTFILE '/content.csv' FIELDS TERMINATED BY ',' ESCAPED BY '\\' OPTIONALLY ENCLOSED BY '"' ...

perl - text processing - output to csv file

Hi, Is there a way in perl to export data from a file to csv file. What I mean is, Say I have a file as follows.. field1=value1,filed2=value2 field1=value3,filed2=value4 field1=value5,filed2=value6 I want to export this to excel format as follows. field1 field2 value1 value2 value3 value4 value5 value6 anyway of doing this?? ...

Tab formatter tool to prepare array data

Is there a tool that can take this: Attack,Decay,Sustain,Release 45,-1,26,55 "VERY LONG TEXT",false,true,true 0,0,1,1 and output it in a tabbed-format like this: Attack, Decay, Sustain, Release 45, -1, 26, 55 "VERY LONG TEXT", false, true, true 0, 0, 1, 1 I need it...

Integrating with 500+ applications

Our customers use 500+ applications and we would like to integrate these applications with our. What is the best way to do that? These applications are time registration applications and common for most of them is that they can export to csv or similar, some of them are actually home-brewed excel sheets where time is registered. The bes...

import on csv to sqlite3 crashes

Hello, I have a csv file that is comma delimited. I have no problem with the importing aspect of it except for when the import reaches a line like this: 1,2,3, Canada's,5, 6,7 The import crashes when it reaches the single quote. Does anyone know of a program I could use to import my csv file in to sqlite database without having to get...

regex to split line (csv file)

I am not good in regex. Can some one help me out to write regex for me? I may have values like this while reading csv file. "Artist,Name",Album,12-SCS "val""u,e1",value2,value3 Output: Artist,Name Album 12-SCS Val"u,e1 Value2 Value3 Update: I like idea using Oledb provider. We do have file upload control on the web page, th...

perl plotting for multiple datasets in .csv file

Hi, I have a .csv file with the following data.(I open CSV file as comma separated file) file1 date1 1 76.09 date10 10 87.09 date11 11 89.89 date2 2 66.5 date3 3 78.89 date4 4 87.98 date5 5 57 date6 6 57.98 date7 7 34.32 date8 8 45.76 date9 9 34.99 file2 date...

Help with exploding a name in PHP and writing back into a .CSV file

I wrote the code below to split up a fullname from a .csv file into a first name, middle name, and last name. It works well and gives the following kind of output: Eric,T.,Nolan Mary,,Worth Jim,T.,Lane E.,Thomas,Powell William,Reilly,Smith Johnny,,Depp Stevie,de,la Soul I can get it to print to the screen, but need help putting it b...

Exporting to CSV using Winforms (built in)

Hi, Is there a way to implement csv exporting from a datagrid, using .NET 2.0 Winforms? Thanks ...

How can you parse excel CSV data that contains linebreaks in the data?

I'm attempting to parse a set of CSV data using PHP, but having a major issue. One of the fields is a long description field, which itself contains linebreaks within the enclosures. My primary issue is writing a piece of code that can split the data line by line, but also recognize when linebreaks within the data should not be used. Th...

Importing csv file into postgres

Using Mysql Administrator GUI tool - I have exported some data tables retrieved from an sql dumpfile into csv files. I then tried to import these csv files into a postgres database using the postgres COPY command. I've tried entering "COPY articles FROM '[insert .csv dir here]' DELIMITERS ',' CSV;" and also the same command without the ...

How can I prepare the logs or textfiles to be read by MySQL using Load DATA INFILE INTO ?

What is the best way to prepare the log files before inserting their values in the MYSQL database using LOAD DATA INFILE '/tmp/someFile.txt' INTO TABLE How can I make sure and make the data log file ready to be read by such command ? Someone told me by scripting (using sed,grep,cat,sub ...) .. how can I do that or what are the to...

How do I import .csv file from Google Docs into javascript

Hello, Another newbie question. I would like to be able to import a .CSV spreadsheet from Google Docs into javascript so that I can parse it, and then extract the bits I want into an array. I can do the second bit, but what I can't work out is what to write to pull in the .csv using the Google Docs URL so that it's available as a stri...

CSV, DictWriter, unicode and utf-8

Hi, I am having problems with the DictWriter and non-ascii characters. A short version of my problem: #!/usr/bin/env python # -*- coding: utf-8 -*- import codecs import csv f = codecs.open("test.csv", 'w', 'utf-8') writer = csv.DictWriter(f, ['field1'], delimiter='\t') writer.writerow({'field1':u'å'.encode('utf-8')}) f.close() Giv...

Using csv modele to extract specific lines of text from a larger file

So I'm extracting the lines that I want from this larger file using this program: import csv name = ['NAMETHEFIRST,' 'NAMEANOTHERNAME '] data = csv.reader(open('C:\\bigfile.csv')) with open('C:\\smalldataset.xcl','w') as outf: csv.writer(outf).writerows(l for l in data if l[0] in name) The program runs. However I am only getting...

splitting space delimited entries into new columns in R

I am coding a survey that outputs a .csv file. Within this csv I have some entries that are space delimited, which represent multi-select questions (e.g. questions with more than one response). In the end I want to parse these space delimited entries into their own columns and create headers for them so i know where they came from. F...

Python csv string to array

Anyone know of a simple library or function to parse a csv encoded string and turn it into an array or dictionary? I don't think I want the built in csv module because in all the examples I've seen that takes filepaths, not strings. Thank you ...