October 09, 2024, 03:48:49 PM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


CSV Inputter

Started by Brian, October 02, 2014, 12:48:46 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Brian

Hi,

I've been messing just lately with CSV files (again!) using the Microsoft ODBC Text/CSV reader

This driver needs a schema.ini file to be in the SAME directory as the CSV file to be opened,
pointing to the name of the CSV file, with the appropriate instructions to create the listing.
This program creates a schema.ini on the fly, and then deletes it when the listview is populated

Ideally, I would like the program to have a look at the contents of the CSV file to be opened,
calculate the number of columns, and then write the schema accordingly. Something to look
at later, I suppose

Please find an IWB program and a sample CSV file. The CSV file looks convincing, but I am assured
it is a mish-mash of names and numbers, etc, that don't mean anything. Got it off the internet

If anyone comes up with any improvements, I would be over the moon!

Have fun,

Brian

billhsln

If I am reading, the following should do what you are looking for in a schema.ini:


[Sample.csv]
Format=CSVDelimited
ColNameHeader=True
MaxScanRows=0


See:  http://msdn.microsoft.com/en-us/library/ms709353(v=vs.85).aspx

Hope that helps,
Bill
When all else fails, get a bigger hammer.

Brian

Thanks, Bill,

I must admit I got a bit confused when I was reading up on the schema settings!

I also have a file with pipes (|) in as the delimiter, and this can be read in by substituting the
Format=CSVDelimited setting with Format=Delimited(|)

Brian