[PYTHON] Memorandum (difference between csv.reader and csv.dictreader)

** You can automate it with python, right? Nice to meet you, so I'll do my best Record Part 2 **

Used in record 1 (https://qiita.com/wellwell3176/items/8e9a31d1595cdde89498) I didn't understand "csv.dict reader" well, so I looked it up and found out somehow.

Or rather, I feel that there is a problem with the word dictionary format ... Searchability is bad ... Searchability is not bad ...?

As far as I investigated, it seems that the difference is whether the information written in the first line is treated as data or as a heading. I tried to make a ponchi-e because I can't understand anything unless I put it in the figure, but it should be in the figure below.

image.png <Fig. 1: Difference between reader and dict reader>

If the first line of the CSV data contains a heading (such as "No." or "age") instead of the data, The dict reader seems to be easier to handle. You should be able to write "get the average value of the data in the 1st to 70th rows of the age column".

On the other hand, if you use reader for CSV with headings, you can say "Average value of data in rows 2 to 71 of the second column". It's hard because you have to always consider the two points of "what information is stored in what column?" And "the first row is not included in the data".

Roughly speaking, let's move on with this understanding.

It's not like making an independent article, but it's a memorandum, and I'll leave it for each theme.

Recommended Posts

Memorandum (difference between csv.reader and csv.dictreader)
Difference between process and job
Difference between "categorical_crossentropy" and "sparse_categorical_crossentropy"
Difference between regression and classification
Difference between np.array and np.arange
Difference between MicroPython and CPython
Difference between ps a and ps -a
Difference between return and print-Python
Difference between Ruby and Python split
Difference between list () and [] in Python
Difference between SQLAlchemy filter () and filter_by ()
Difference between == and is in python
(Note) Difference between gateway and default gateway
Difference between Numpy randint and Random randint
Difference between sort and sorted (memorial)
Difference between python2 series and python3 series dict.keys ()
[Python] Difference between function and method
Difference between SQLAlchemy flush () and commit ()
Python --Difference between exec and eval
[Python] Difference between randrange () and randint ()
[Python] Difference between sorted and sorted (Colaboratory)
[Xg boost] Difference between softmax and softprob
difference between statements (statements) and expressions (expressions) in Python
[Django ORM] Difference between values () and only ()
Difference between PHP and Python finally and exit
Difference between @classmethod and @staticmethod in Python
Difference between append and + = in Python list
Difference between nonlocal and global in Python
Difference between linear regression, Ridge regression and Lasso regression
[Python] Difference between class method and static method
Difference between docker-compose env_file and .env file
[Python Iroha] Difference between List and Tuple
[python] Difference between rand and randn output
speed difference between wsgi, Bottle and Flask
Difference between numpy.ndarray and list (dimension, size)
Difference between ls -l and cat command
Difference and compatibility verification between keras and tf.keras # 1
What is the difference between `pip` and` conda`?
Difference between using and import on shield language
[python] Difference between variables and self. Variables in class
About the difference between "==" and "is" in python
About the difference between PostgreSQL su and sudo
What is the difference between Unix and Linux?
Center difference and forward difference
Can BERT tell the difference between "candy (candy)" and "candy (rain)"?
Between parametric and nonparametric
Difference between Ruby and Python in terms of variables
What is the difference between usleep, nanosleep and clock_nanosleep?
Difference between Numpy (n,) and (n, 1) notation [Difference between horizontal vector and vertical vector]
Difference between return, return None, and no return description in Python
How to use argparse and the difference between optparse
What is the difference between a symbolic link and a hard link?
Python module num2words Difference in behavior between English and Russian
Python> Difference between inpbt and print (inpbt) output> [1. 2. 3.] / array ([1., 2., 3.], dtype = float32)
Understand the difference between cumulative assignment to variables and cumulative assignment to objects
List concatenation method in python, difference between list.extend () and “+” operator
Difference between SQLAlchemy back_populates and backref and when neither is used
The difference between foreground and background processes understood by the principle
Correspondence between pandas and SQL
Conversion between unixtime and datetime
Collaboration between PTVS and Anaconda