The important thing here is that you have iterator pointing to the actual data in the file stream, and a bunch of dynamically loaded column headers. You can now convert the file to a true CSV, or do something else with it. Header = get_words_and_positions(next(iterator)) \ You can convert it to a different format, or even import it into a pandas DataFrame directly. If you do it right, you will be left with an iterator over a file stream that you can use to process the remainder of the data as you wish. You can skip the first two lines, and combine the next two. It looks like you can combine the header rows dynamically based on a word's position in the line.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |