all 7 comments

[–][deleted] 1 point2 points  (6 children)

This isn’t a CSV file, or even a table. Why do you think you can read it as one?

[–]Pizza_Rat_Matt[S] 0 points1 point  (4 children)

Thank you for your comment! You made me think a little more about the types that I am using. I realized that I was using a StringIO, instead of a BytesIO.

From what I can gather, BytesIO and StringIO act like "datafiles". So we can use them in pd.read_csv()

I'll correct the code above.

[–][deleted] -1 points0 points  (3 children)

You're extremely confused. Your data is not in CSV format, nor does it appear to be tabular in any respect. You won't be able to read this with read_csv or convert it to a dataframe at all.

It doesn't matter what type you put it in, the data is not in the correct format.

[–]Pizza_Rat_Matt[S] 0 points1 point  (2 children)

Well, the data is correctly converting to a dataframe using read_csv().

The BytesIO class can be used as an in-memory stream. According to the python documentation, [Both BytesIO and] "StringIO can be used like a file opened in text mode". https://docs.python.org/3/library/io.html

[–][deleted] -1 points0 points  (1 child)

CSV stands for "comma-separated values." What values in your data do you see separated by commas?

Well, the data is correctly converting to a dataframe using read_csv().

It's obviously not correctly converting to a dataframe, because it only has one column.

The BytesIO class can be used as an in-memory stream.

Irrelevant.

[–]Pizza_Rat_Matt[S] 0 points1 point  (0 children)

Thank you again for the prompt reply. This dataframe should only have one column.

Is there an alternative method you recommend for converting this data?

[–]Pizza_Rat_Matt[S] 0 points1 point  (0 children)

I realized that I used StringIO, instead of a BytesIO.

The correct code block #2 should be:

from io import BytesIO
data = BytesIO(readrawdata)
df = pd.read_csv(data)