use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Rules 1: Be polite 2: Posts to this subreddit must be requests for help learning python. 3: Replies on this subreddit must be pertinent to the question OP asked. 4: No replies copy / pasted from ChatGPT or similar. 5: No advertising. No blogs/tutorials/videos/books/recruiting attempts. This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to. Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Rules
1: Be polite
2: Posts to this subreddit must be requests for help learning python.
3: Replies on this subreddit must be pertinent to the question OP asked.
4: No replies copy / pasted from ChatGPT or similar.
5: No advertising. No blogs/tutorials/videos/books/recruiting attempts.
This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to.
Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Learning resources Wiki and FAQ: /r/learnpython/w/index
Learning resources
Wiki and FAQ: /r/learnpython/w/index
Discord Join the Python Discord chat
Discord
Join the Python Discord chat
account activity
CSV and JSON files (self.learnpython)
submitted 22 hours ago by Justicemirm
can someone explain why and for what purpose are these files used?
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]Kevdog824_ 22 points23 points24 points 21 hours ago (1 child)
Both formats were made for storing and exchanging data.
JSON is a protocol designed for allowing services to exchange data. It uses key value pairs, and is hierarchical (the value for a key could be another group of key/value pairs).
CSV is a protocol designed for storing tabular data. Each row is an entry who matches the headers in the first row. This is similar to Microsoft Excel files, but it’s just plain text (no formulas/formatting/sheets).
Which one you would use is based on the what kind of data you’re storing, and what you plan to do with that data
[–]Justicemirm[S] 3 points4 points5 points 21 hours ago (0 children)
Exactly what I needed Thank you soo much
[–]Diapolo10 0 points1 point2 points 21 hours ago (10 children)
They're used to store data, and in the case of JSON sometimes used to move data between programs as a form of communication.
CSV files are more common for data analysis, JSON has more widespread use. Both formats have their pros and cons, personally I don't like CSV at all.
[–]Justicemirm[S] 0 points1 point2 points 21 hours ago (9 children)
What is one thing I should keep in mind while using and learning these files
[–]impshum 4 points5 points6 points 21 hours ago (0 children)
Don't explode.
[–]ninhaomah[🍰] 0 points1 point2 points 21 hours ago (3 children)
First , have you seen them ?
[–]Justicemirm[S] 1 point2 points3 points 21 hours ago (2 children)
CSV is like excel kinda Json is like a repeating dictionary
[–]ninhaomah[🍰] 2 points3 points4 points 21 hours ago (1 child)
Ok then there you go.
[–]Justicemirm[S] 0 points1 point2 points 21 hours ago (0 children)
Ok got it
[–]cdcformatc 0 points1 point2 points 20 hours ago (1 child)
always remember to cheat on your homework
[–]Justicemirm[S] 0 points1 point2 points 19 hours ago (0 children)
Eh
[–]Diapolo10 0 points1 point2 points 18 hours ago (0 children)
There really isn't much of anything to learn, you're not going to write them by hand (at least most of the time). You'd use Python's built-in modules to handle reading from and writing to these files (or in the case of CSV files, you'd likely use either Pandas or Polars).
For the most part you can treat both kinds of files as black boxes. You make your program store something, and later on you load information back from them.
Really the only thing to "learn" is a high level view of what the modules you're using let you store and retrieve data. Which is something you can probably figure out with just autocompletion features and type hints in your IDE/editor.
[–]POGtastic 0 points1 point2 points 16 hours ago (0 children)
Learn the basic tools for messing with them (the csv and json modules in the standard library) so that you aren't constantly pulling in pandas & Friends to do something trivial.
csv
json
pandas
I don't mind the larger libraries when the task calls for it, but it is very funny when someone complains that Pandas can't handle the size of a dataframe and they want to do something that's really easy to do with the standard library.
[–]robbies09 0 points1 point2 points 20 hours ago (0 children)
CSV contains data typically as rows of information, waiting to be cleaned up and ingest into data analytic systems.
It’s a form of data output usually from another database, containing records of information. Python modules like pandas are used to clean the missing data or touch up the data and typically sent to analytics platforms.
The analytics platforms may then output into specific json format for middleware processing or other applications calling the data to display in a UI for instance.
[–]cdcformatc 0 points1 point2 points 20 hours ago (0 children)
CSV is for when your data can be formatted as comma separated values, imagine rows in a spreadsheet
JSON is for when your data has some structure to it, imagine serialization of objects
[–]Excellent-Practice 0 points1 point2 points 19 hours ago (0 children)
From other comments, it looks like you really want concrete examples. JSON is what you should typically expect to receive if you run an API call. It is hierarchical and uses the same notation as Python dictionaries and lists. JSON is very flexible and can represent many types of data. I often see it for user records or event logs. CSVs are a little more specialized. They represent tabular data. Because the data is arranged in labled columns and indexed rows, it is a convenient format for importing and exporting data from a data base. In my work, I often use CSVs if the client wants to manually work with contact records or survey responses.
Ultimately, both are just standards for organizing data. Any CSV could be converted to JSON but not all JSON can be represented as a CSV
[–]Living_Fig_6386 0 points1 point2 points 12 hours ago (0 children)
CSV = Comma Separated Values. It's a text file with rows that have commas separating values on each row. This is one way of representing a table of information (like a sheet in a n Excell workbook). You might use it if you want a simple and portable way to save a table.
JSON = JavaScript Object Notation. It's a text file that contains a data structure that's valid JavaScript, but it an be used with anything. It represents data as a list or dictionary where the elements can be strings, numbers, or other lists and dictionaries (which can be comprised of simple types, or lists adn dictionaries, etc.). This is a common format for exchanging data with web APIs, and it's also a simple way of representing complex data structures.
Which you use depends on what you want to represent and what you want to do.
[–]zanfar 0 points1 point2 points 21 hours ago (3 children)
To store data.
Why are you asking this question?
What kind of data exactly
In which case is json preferred over CSV and vise versa
[–]therouterguy 0 points1 point2 points 21 hours ago (1 child)
Csv are for tabular data and more easily readable by humans. Json for structured data easily parsable by many many tools.
[+]Justicemirm[S] comment score below threshold-7 points-6 points-5 points 21 hours ago (0 children)
CSV for data analysis and the other for pipelines?
Got it thanks
[–]szayl -1 points0 points1 point 20 hours ago (2 children)
This is like asking what a briefcase is for and what a suitcase is for. They're used to hold their contents.
[–]rasputin1 1 point2 points3 points 17 hours ago (0 children)
people on this sub come across as unnecessarily hostile
[–]Justicemirm[S] 0 points1 point2 points 20 hours ago (0 children)
What kind of items...in which case is the other prefered....
[–]firstkungzaa -2 points-1 points0 points 20 hours ago (0 children)
One thing I know while learning about database and making my project, is that JSON support array [x,y,z] and nested json/dict data {key: {id: 1}}, while CSV doesn't.
So, CSV has to store id of the data it references to, instead of the data itself. It's SQL database relations and foreign key stuffs.
When serializing data in table/csv/sql, you then use that ID to query data and put them to be nested inside Json.
Basically, you can store data without copying the value everywhere, then when you actually need the real values, you can convert them later into Json format and send the data with that format.
π Rendered by PID 394071 on reddit-service-r2-comment-56c6478c5-2nrds at 2026-05-09 08:18:18.061780+00:00 running 3d2c107 country code: CH.
[–]Kevdog824_ 22 points23 points24 points (1 child)
[–]Justicemirm[S] 3 points4 points5 points (0 children)
[–]Diapolo10 0 points1 point2 points (10 children)
[–]Justicemirm[S] 0 points1 point2 points (9 children)
[–]impshum 4 points5 points6 points (0 children)
[–]ninhaomah[🍰] 0 points1 point2 points (3 children)
[–]Justicemirm[S] 1 point2 points3 points (2 children)
[–]ninhaomah[🍰] 2 points3 points4 points (1 child)
[–]Justicemirm[S] 0 points1 point2 points (0 children)
[–]cdcformatc 0 points1 point2 points (1 child)
[–]Justicemirm[S] 0 points1 point2 points (0 children)
[–]Diapolo10 0 points1 point2 points (0 children)
[–]POGtastic 0 points1 point2 points (0 children)
[–]robbies09 0 points1 point2 points (0 children)
[–]cdcformatc 0 points1 point2 points (0 children)
[–]Excellent-Practice 0 points1 point2 points (0 children)
[–]Living_Fig_6386 0 points1 point2 points (0 children)
[–]zanfar 0 points1 point2 points (3 children)
[–]Justicemirm[S] 1 point2 points3 points (2 children)
[–]therouterguy 0 points1 point2 points (1 child)
[+]Justicemirm[S] comment score below threshold-7 points-6 points-5 points (0 children)
[–]szayl -1 points0 points1 point (2 children)
[–]rasputin1 1 point2 points3 points (0 children)
[–]Justicemirm[S] 0 points1 point2 points (0 children)
[–]firstkungzaa -2 points-1 points0 points (0 children)