DEV Community

loading...

Which is faster to store data using Python, CSV or text?

marianvelani profile image MarianVelani Originally published at pyclick.blogspot.com Updated on ・2 min read

Answer

The fastness of CSV and text file depends on the use of it. Deep down both CSV and text file store data in the same way on memory.
Text file store data with no rules and standard format it directs store string as plain text. And another hand CSV file stores data in standard formate as rows and columns.

the column is generally separated by a comma but it is ok if we use other character value. The full from of CSV is Comma separated value but also mean character separate value.

Who is faster to store data using Python CSV or text?

so at the time of retrieve data from the file, we have a specific address for specific data so it is easy for retrieve data like name, age, address, id or many more we can imagine.
In CSV file we can able to store categorical of data because of it formate which is not possible in the text file so in case of categorical data CSV is faster than text.

And if we don't have categorical data and has single formatted data on the whole text file so it is easy to retrieve so in this case text file is faster than CSV file. but the text must have only one kind of data like a paragraph of the book.

Discussion (3)

pic
Editor guide
Collapse
lillybet2 profile image
LillyBet2 • Edited

You are correct that it's more convenient to store different data in different formats. I first get to know about CSV files this year while working with Python. I read the article what is CSV on the advice of my friend, and it became clear to me. I am new to Python and am learning it on my own. I have some difficulties and would like to ask for expert advice here. For example, I have a problem saving the text from the CSV file as a variable used later in the code. I would be very grateful if someone could explain this to me and help me. I'm trying hard to learn, and hopefully, I can get a better position at work.

Collapse
pywannabe profile image
Pythonic Wannabe

Marian, thanks for these good points.

I hope you don't mind if I make a suggestion on the title. It would be more easily understood as: "Which is faster to store data using Python, CSV or text?"

Collapse
marianvelani profile image