csv

CSV File Upload

using System; using System.Collections.Generic; using System.Text; using System.IO; using System.Data; using System.Text.RegularExpressions; namespace pro.Classes { public class CSVParser { Stream _stream; /// /// Creates Parser from Stream /// /// public CSVParser(Stream aStream) { ...

FasterCSV: Read Remote CSV Files

I can't seem to get this to work. I want to pull a CSV file from a different webserver to read in my application. This is how I'd like to call it: url = 'http://www.testing.com/test.csv' records = FasterCSV.read(url, :headers => true, :header_converters => :symbol) But that doesn't work. I tried Googling, and all I came up with was...

Using "with" statement for CSV files in Python

Is it possible to use the with statement directly with CSV files? It seems natural to be able to do something like this: import csv with csv.reader(open("myfile.csv")) as reader: # do things with reader But csv.reader doesn't provide the __enter__ and __exit__ methods, so this doesn't work. I can however do it in two steps: impor...

Import multiline csv files into Excel internationally

There is a .csv file we would like to distribute to our customers, it contains multiline entries (i.e. entries with newlines). Depending on the language settings of the customers, the file may or may not be correctly imported into Excel. Normally, we would suggest to use to Import the file, but there seems to be some bug with the multili...

How can I best parse this comma delimited text file?

Hi, I am trying to figure out the best way to parse this comma delimited text file. Here is an excerpt: bldgA, fred, lunch bldgA, sally, supper bldgB, bob, parking lot bldgB, frank, rooftop ... What I am trying to do is read "bldgA" and then I want the person (2nd column), "fred" for example. But I don't want to parse the file look...

What's the best way to export UTF8 data into Excel?

So we have this web app where we support UTF8 data. Hooray UTF8. And we can export the user-supplied data into CSV no problem - it's still in UTF8 at that point. The problem is when you open a typical UTF8 CSV up in Excel, it reads it as ANSII encoded text, and accordingly tries to read two-byte chars like ø and ü as two separate charact...

Is there such a thing as TapeMACS data file formatting?

I'm trying to do an estimate for a data integration, and the client sent across some files for their current system that appear to be in TapeMACS format? It is not a comma-separated or tab-delimited format, and there appears to be a layout that maps to the file with "Field Name", "Description", "Format" and "Position" specified. Is this ...

Dump a mysql database to a plaintext (CSV) backup from the command line.

I'd like to avoid mysqldump since that outputs in a form that is only convenient for mysql to read. CSV seems more universal (one file per table is fine). But if there are advantages to mysqldump, I'm all ears. Also, I'd like something I can run from the command line (linux). If that's a mysql script, pointers to how to make such a t...

Hibernate/Spring application - export to CSV

I'm writing a web application using Spring/Hibernate that displays a report to a user, I would like to allow the user to export the results to a CSV file. Can anyone suggest an efficient way to output Hibernate query results to a CSV file? Thanks! ...

Regular expression for parsing CSV in PHP

I already managed to split the CSV file using this regex: "/,(?=(?:[^\"]\"[^\"]\")(?![^\"]\"))/" But I ended up with an array of strings that contain the opening and ending double quotes. Now I need a regex that would strip those strings of the delimiter double quotes. As far as I know the CSV format can encapsulate strings in double q...

Python: Use the codecs module or use string function decode?

I have a text file that is encoded in UTF-8. I'm reading it in to analyze and plot some data. I would like the file to be read in as ascii. Would it be best to use the codecs module or use the builtin string decode method? Also, the file is divided up as a csv, so could the csv module also be a valid solution? Thanks for your help. ...

C# How to catch empty rows in a CSV file using CSVReader?

Hi all, I'm using C# 2005 and the CSVreader class, all works well apart from when the CSV file contains an empty row at the end: Example: 1,2,3,4,5 2,3,5,6,7 ,,,, My program errors as there are no values here, the problem is that not all columns are contain a value so the 2 rows below would be valid. 1,2,,4,5 2,,5,6,7 but an empt...

SSIS - Is there a Data Flow Source component that will handle CSV files where the column order may change?

We have written a number of SSIS packages that import data from CSV files using the Flat File Source. It now seems that after these packages are deployed into production, the providers of these files may deliver files where the column order of the files changes (Don't ask!). Currently if this happens, our packages will fail. For exa...

How can I disable quoting in the Python 2.4 CSV reader?

I am writing a Python utility that needs to parse a large, regularly-updated CSV file I don't control. The utility must run on a server with only Python 2.4 available. The CSV file does not quote field values at all, but the Python 2.4 version of the csv library does not seem to give me any way to turn off quoting, it just allows me to...

Is there a publicly available list of the US States in machine readable form?

Where can I find a list of the US States in a form for importing into my database? SQL would be ideal, otherwise CSV or some other flat file format is fine. Edit: Complete with the two letter state codes ...

Mapping CSV to a Model

I am writing a simple CSV to XML processor in Java. I am using JAXB to generate a model in java from a DTD. I need to process the CSV format into this model, and then marshall it into the XML that complies to the DTD. I am using JAXB to marhall the data from the Java model to the XML. I have to write the CSV-Model mapping myself. At th...

Ruby CSV 'illegal quoting' even though quotes are escaped

I'm parsing a tab-delimited file using FasterCSV: csv_rows = FasterCSV.readlines(file_location, {:col_sep=>"\t"}) When I parse this I get an 'Illegal quoting on line 1.' error. The line contains this text: ...around \"foo bar\" with... Is there another way to escape quotes that might work? Thanks, ...

Can I use a CSV file like a (MSsql or mysql or BDE database) in C++ Builder?

I apologise in advance if this question isn't very specific. Would it be possible to do the following. when the application loads read the contents of a CSV file into a dataset. while the application is running operate on that dataset exactly as if it were a mysql or mssql or bde database (run queries. insert records. delete reco...

What data provider for a tclientdataset using a csv file?

I have a tclientdataset. It is used to get data to and from a csv file. The csv file may not exist until the application is run. I have the following code in a tbutton... ClientDataSet1->FileName = "c:\\testdata.csv"; ClientDataSet1->Open(); AddFiles(Edit1->Text); ClientDataSet1->SaveToFile("c:\\testdata.csv"); When I run the ap...

Speed: Java serialization or csv?

I have a large array of Java simple structs (consists of just primitive members) and I need to save and load them from and to a file What would be faster, implementing java.io.Serializable and using read/writeObject or overriding toString() / toCSV(), adding a new constructor and reading/writing to text file? I want to avoid b...