Cannot understand how to make CSV files

CAN SOMEONE HELP ME EXPLAIN CSV FILES ONCE AGAIN. I seriously cannot understand it as it is a bit complicated .

Not sure what your specific question is. CSV files are a specifically formatted text file with rules on how the data is stored so that it can be imported into other programs.

CSV can have different rules. For example, is there headers on row 1? Are there double quotes around every field? That makes CSV a little unreliable.

If you use a spreadsheet like Excel and save the data in CSV format, it could be in a format that is not going to work. It’s especially challenging where there are double-quotes used to delimit fields and there are also double-quotes inside your data.

As opposed to CSV, I prefer TAB-Delimited files. TABS are less likely to appear in your data so the formatting of the document is more trustworthy.

JSON files are far more reliable than either of those, so when you can use that, it’s better.

Now — in Python — there are functions that can convert your data into CSV format. You can read more about that here:

Because CSV data seems to be rows and columns, you’ll basically layout what one row might look like and that will also be true for every other row. If your data is not that consistent, you’ll need to insert nulls where data should exist.

If you have other questions, please be precise and show code samples of what you are asking about.

Jerry

2 Likes