Skip to content Skip to sidebar Skip to footer

How To Read First 2 Rows Of Csv From Google Cloud Storage

I need to read first 2 rows of csv file and store that in array to determine file_type,reportingdate and other metadata. My file is in Google cloud Storage.How can I read first 2 r

Solution 1:

Due to the function name, I am assuming that the content variable is one very long string. If that is the case, then there ought to be newline characters in the string. You can simply split the string using newline as a delimiter and grab the first two values. Something like this:

lines = content.split('\n')[:2]

Post a Comment for "How To Read First 2 Rows Of Csv From Google Cloud Storage"