

I was really surprised how easy and flexible it was to read this kind of data with Delphi. For that reason most 3rd party frameworks offer methods to import data into their grids and databases. Is there any way to check the file the user submits first to make sure it truly is a csv file, and throw an error at them if they try to submit another file type. Reading comma-separated or tab-separated data from text files (also known as flat files) is a rather common task that developers have to deal with. I figure the easiest way is to let the users send me a csv file with the search criteria in it, and Ive managed to build a looping search that can parse the csv (using SPLIT). One major potential gotcha with Excel CSV files is that CSV files.Īt least in a Swedish Excel, these files are known as xx.SKV instead of.Įnglish.CSV files, so Ill always have to use Import for those (or change. Most fo the simple converters (such as commaText) only apply to a.

Generally the representation of CSV is so variable its worth writing.Įxcel is normally OK though and the format can be controlled with. Here is some code I wrote years ago to quickly parse a CSV field. This situation can nonetheless be handled by setting property IgnoreEmptyLines to true.
Consequently, theOne thing to add is that if you have a inside a text field, you should escape it and write it as. Values containing spaces (in a.csv file) dont require quotes, because a space is not a delimiter. However the file is generated by Excel and does not place quotes around.

Question: Sometimes you dont need fancy parsing classes- reading a CSV file line by line is one such case.
