7

I am working on a python project that does some analysis on csv files. I know there is no well-definedstandard for csv files, but as far as I understood the definition (https://www.rfc-editor.org/rfc/rfc4180#page-2), I think that a csv file should not contain more than one table. Is this thinking correct, or did I misunderstood the definitions?

How often do you see more than one table in csv's?

Community
  • 1
  • 1
Zweistein
  • 293
  • 1
  • 4
  • 11
  • Is this directly related to your project, or are you just curious? – AMC Mar 13 '20 at 00:22
  • Ah the Moment I am using some csv libraries, but all of them do not support more than one table in a file. I just wanted to make sure that people in general do not expect to be able to use such files with more tables when reading about a csv lib. – Zweistein Mar 13 '20 at 09:08
  • @Zweistein You can find how the tables are split by reading it in a text editor. Then write a script to find the lines where the tables are split, according the pattern you found. Finally, write another script to read one chunk at a time, using any CSV lib. – Edward Jan 14 '23 at 10:37

1 Answers1

6

You are correct. There is no universal accepted standard. The definition is written to suggest that each file contains one table, and this is by far the most common practice.

There's technically nothing stopping you from having more than one table, using a format you decide on and implement and keep consistent. For instance, you could parse the file yourself and use a line with 5 hyphens to designate a separate table.

However I wouldn't recommend this. It goes against the common practice, and you will eliminate the possibility of using existing CSV libraries to help you.

tmdesigned
  • 2,098
  • 2
  • 12
  • 20