<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Tifey_</title>
    <description>The latest articles on DEV Community by Tifey_ (@weber).</description>
    <link>https://dev.to/weber</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F791278%2Fbb9760d7-ac55-4f73-b937-6a6e930e02a8.jpg</url>
      <title>DEV Community: Tifey_</title>
      <link>https://dev.to/weber</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/weber"/>
    <language>en</language>
    <item>
      <title>How to use Pandas for Csv data in Python </title>
      <dc:creator>Tifey_</dc:creator>
      <pubDate>Wed, 19 Jan 2022 12:05:47 +0000</pubDate>
      <link>https://dev.to/weber/how-to-use-pandas-for-csv-data-in-python-3agc</link>
      <guid>https://dev.to/weber/how-to-use-pandas-for-csv-data-in-python-3agc</guid>
      <description>&lt;p&gt;In the last article,  you learnt how to use the python csv module in order to work with csv files,  you learnt the conversion of csv files into dictionaries and lists. &lt;/p&gt;

&lt;p&gt;In this article, we are going to treat a software module called Pandas.  It mainly works with structured data I.e csv data, tabular data, etc. It's no doubt that most Python programmers make use of this library when they come across csv files and this is due to it flexibility and usability. &lt;/p&gt;

&lt;h2&gt;
  
  
  How does Pandas work
&lt;/h2&gt;

&lt;p&gt;.&lt;br&gt;
The library arranges csv files into a tabular form making the first rows of each columns the head of the table. These heads could be used as an attribute to access the items in its columns. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What you'll learn&lt;/strong&gt; &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Installing Pandas &lt;/li&gt;
&lt;li&gt;Data frame and series.&lt;/li&gt;
&lt;li&gt;Using Pandas to convert a csv into list.&lt;/li&gt;
&lt;li&gt;Pandas to convert csv into dict&lt;/li&gt;
&lt;li&gt;Calculating mean, median mode and other statistical functions. &lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;
  
  
  Installing Pandas
&lt;/h2&gt;

&lt;p&gt;Visit the pypi website and search for the pandas library. Click no its latest version and install. It will be configured in you python editor automatically. &lt;/p&gt;

&lt;p&gt;Using Pandas to read csv files&lt;br&gt;
Pandas is a library made specially for structural and tabulated datas so it does work on a csv file.&lt;br&gt;
To do this:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;import the pandas in your main.py&lt;/li&gt;
&lt;li&gt;call the read_csv() function.
The read_csv() takes in the file path of the csv file in a strung type. 
Data = pandas.read_csv("my_cs_file.csv")&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  DATAFRAME AND SERIES
&lt;/h2&gt;

&lt;p&gt;.&lt;br&gt;
DataFrame is a 2-dimensional labeled data structure with columns of potentially different types. You can think of it like a spreadsheet or SQL table, or a dict of Series objects. It is generally the most commonly used pandas object.  &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;How to create a dataframe&lt;/em&gt;&lt;/strong&gt;.&lt;br&gt;
A dataframe accepts list nested in a dictionary. You will need to create the nested dictionary before you could create a dataframe&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Import pandas as pd
Dict = {"Names" : ["Scott", "Abey", "Boluwatife ", "Thomas ", "Mike",],
"Scores" : [67, 82, 98, 46, 89]
}
df =pd.DataFrame(Dict) 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can print the df to see how it looks, exactly like a table. &lt;/p&gt;

&lt;p&gt;N:B a list is nested in the dictionary. The keys in the dictionary will be the heads of the tables and each value which is a list will be the items in heads &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Series&lt;/strong&gt;:&lt;br&gt;
Series is a one-dimensional labeled array capable of holding any data type (integers, strings, floating point numbers, Python objects, etc.). The axis labels are collectively referred to as the index. The basic method to create a Series is to call: &lt;/p&gt;

&lt;blockquote&gt;
&lt;blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;s = pd.Series(data, index=index) &lt;/p&gt;
&lt;/blockquote&gt;
&lt;/blockquote&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;How to create a Series&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Dict = {"Names": "Fola",
"Score":12} 

df_series = pd.Series(Dict) 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;em&gt;Get columns of dataframe&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
Columns can be accessed by columns heads. Taking the dict as an example.  Of you want to access the name of students in the table. &lt;/p&gt;

&lt;p&gt;&lt;code&gt;Names = df.Names &lt;br&gt;
        Or &lt;br&gt;
Names = df["Names"]&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Get rows in a Dataframe &lt;br&gt;
The best way to access a row in pandas dataframe is to check through the column of a table and locate the name of the item at the row we need.&lt;br&gt;
row1= df[df.Names == "Scott"] &lt;/p&gt;

&lt;p&gt;This will print every item in the same row with the name Scott &lt;/p&gt;

&lt;h2&gt;
  
  
  USING PANDAS TO CONVERT CSV INTO LIST.
&lt;/h2&gt;

&lt;p&gt;Unlike the python pre built csv module,  the pandas library already has a method for creating a list from a csv file. &lt;/p&gt;

&lt;p&gt;-----to_list()---&lt;br&gt;
This method takes a file path as a string input. The csv path we need to convert. &lt;br&gt;
Example:&lt;br&gt;
&lt;code&gt;Import pandas as pd &lt;br&gt;
new_list = pd.to_list("file.csv")&lt;/code&gt; &lt;/p&gt;

&lt;p&gt;With these lines of codes, the output will be the list of items in your csv file. Unlike the csv module where you run the for loop for number of times to get what pandas has in just two(2) lines. &lt;/p&gt;

&lt;h2&gt;
  
  
  USING PANDAS TO CONVERT CSV INTO DICTIONARY.
&lt;/h2&gt;

&lt;p&gt;-------to_dict()--------&lt;br&gt;
The method also takes the dataframe as an input and convert its item into dictionary using the head words as the key and other rows as its value. &lt;/p&gt;

&lt;h2&gt;
  
  
  USING PANDAS FOR STATISTICS
&lt;/h2&gt;

&lt;p&gt;The pandas library has also made available method for executing statistical tasks. &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Mean : .mean()
The method takes a list of numbers and return the mean value of it list &lt;/li&gt;
&lt;li&gt;&lt;p&gt;Mode :  .mode()&lt;br&gt;
It takes a list of numbers and returns the number with the highest frequency &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Median: .median()&lt;br&gt;
It takes a list of numbers, arranges them in an ascending order and returns the number at the intersection (middle) &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Product of numbers: .prod()&lt;br&gt;
Accepts a an array of numbers and returns its product.&lt;br&gt;
Cumulative numbers. .cumin()&lt;br&gt;
It takes an array of numbers and returns the cumulative value.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Other available methods are:&lt;br&gt;
.max(), .min(), .quantile,  .cummax(), .var(), etc. &lt;/p&gt;

&lt;p&gt;To know more about the pandas library visit the pandas library documentation &lt;/p&gt;

&lt;p&gt;To have more insight about pandas library;&lt;br&gt;
Visit the pandas documentation library  &lt;br&gt;
&lt;a href="https://pandas.pydata.org/docs/user_guide/index.html"&gt;https://pandas.pydata.org/docs/user_guide/index.html&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;----------------If this was helpful,  kindly react and comment----------------&lt;/p&gt;

</description>
      <category>python</category>
      <category>beginners</category>
      <category>programming</category>
      <category>computerscience</category>
    </item>
    <item>
      <title>How to use Python Csv Module to analyse Csv Files</title>
      <dc:creator>Tifey_</dc:creator>
      <pubDate>Sat, 15 Jan 2022 23:39:23 +0000</pubDate>
      <link>https://dev.to/weber/how-to-use-python-csv-module-to-analyse-csv-files-1m2i</link>
      <guid>https://dev.to/weber/how-to-use-python-csv-module-to-analyse-csv-files-1m2i</guid>
      <description>&lt;p&gt;A CSV file (&lt;em&gt;Comma Separated Values file&lt;/em&gt;) is a type of plain text file that uses specific structuring to arrange tabular data. Because it's a plain text file, it can contain only actual text data—in other words, printable ASCII or Unicode characters . &lt;/p&gt;

&lt;p&gt;When time comes for you to use a Csv file or a spreadsheet in your program. This article will be of great help as you will be able to open and work with csv files, know what modules are used for csv files, modify and work with csv as if they were they were yours&lt;/p&gt;

&lt;h2&gt;
  
  
  Let's get Started
&lt;/h2&gt;

&lt;p&gt;!!! &lt;br&gt;
&lt;strong&gt;Python&lt;/strong&gt; as a high level programming has a pre built module for csv files which is called "csv".&lt;br&gt;
Below are the steps for using Python pre built module to analyse csv files&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Importing the Csv Module&lt;/strong&gt;&lt;br&gt;
Since the module is already prebuilt you will only import else you will need to install&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;import csv &lt;/p&gt;
&lt;/blockquote&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Opening the csv file using the with statement.&lt;/strong&gt;&lt;br&gt;
The with statement is preferred by most Python developers  because it automates the &lt;em&gt;&lt;strong&gt;close()&lt;/strong&gt;&lt;/em&gt; function after using its open().&lt;br&gt;
The &lt;strong&gt;&lt;em&gt;with&lt;/em&gt;&lt;/strong&gt; statement &lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;blockquote&gt;
&lt;p&gt;with open ("notes.csv") as csv_file:&lt;br&gt;
    data=csv.reader(csv_file)&lt;/p&gt;
&lt;/blockquote&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;open()&lt;/strong&gt; : is a python function used to open files in a main.py&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;csv_file&lt;/strong&gt; : is a variable which stores the file that is been open &lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;data&lt;/strong&gt; : is a variable assigned to the information extracted from the csv_file after its been accessed by the csv module.&lt;/li&gt;
&lt;li&gt;.&lt;strong&gt;reader()&lt;/strong&gt; : is a csv function for reading the content of a opened csv file. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;N:B&lt;/strong&gt; the reader() is read only. If you print data variable at this stage, it will generate numbers and code which represents the location of the csv file on the computer ROM.&lt;/p&gt;

&lt;p&gt;**&lt;/p&gt;
&lt;h2&gt;
  
  
  Converting a csv file to List and Dictionary**
&lt;/h2&gt;

&lt;p&gt;After the file is been read by the csv module. You could start making your modifications. You can convert  it to either a list or dictionary. We will walk you through the two  conversions. &lt;/p&gt;

&lt;p&gt;1). &lt;strong&gt;Converting csv file to a list.&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;a. Create an empty stored in a variable.&lt;br&gt;
List  = [].&lt;br&gt;
b. Loop through the data( variable which you use to store the content of the file when the reader() was used).&lt;br&gt;
c. Append each item in the data to your new list. &lt;/p&gt;

&lt;p&gt;Your codes should be in the below format &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--vsNgArQJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1vu0wgc1c8g638pj3jji.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vsNgArQJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1vu0wgc1c8g638pj3jji.jpg" alt="Image description" width="715" height="555"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When the above code is run. It will outpu the  list of items in the csv file beginning from the first row and convert each row to a list type object. It will output the below &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--WE7jSC9---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/738npuw2qsyqiu92noj2.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--WE7jSC9---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/738npuw2qsyqiu92noj2.jpg" alt="Image description" width="720" height="363"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With this, you can work with your csv files like you do with your list objects.&lt;/p&gt;

&lt;p&gt;2). &lt;strong&gt;Converting a csv file to Dictionary.&lt;/strong&gt;&lt;br&gt;
A dictionary works with its keys and values.&lt;br&gt;
To convert a csv file into a dictionary, we will need a key and value. &lt;/p&gt;

&lt;p&gt;In this article, we will use an item in the csv_file as the key and the other as its value since it is of two columns.&lt;br&gt;
a). Create an empty dictionary and assign it to a variable.&lt;br&gt;
b). Loop through the data&lt;br&gt;
c). Add the key and value to the empty dictionary.&lt;br&gt;
Your codes should be in the below format:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--EpZ9ZwDr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/35q0nd5rx746u0khb1yv.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--EpZ9ZwDr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/35q0nd5rx746u0khb1yv.jpg" alt="Image description" width="720" height="601"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The key used in the above is the item at index 0 on each row of the Csv file and its value is that at index 1.&lt;br&gt;
The following would be its output&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--2O8V8jhF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cnsm9nc3j0y5zhe2yr63.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--2O8V8jhF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cnsm9nc3j0y5zhe2yr63.jpg" alt="Image description" width="720" height="322"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Also with the above out you can also treat your Csv file like that of a dictionary. For example you could modify its value,  its key, change the values and keys, and other dictionary features. &lt;/p&gt;
&lt;h2&gt;
  
  
  &lt;em&gt;Now let's advance a little.&lt;/em&gt;
&lt;/h2&gt;

&lt;p&gt;How would it be if we could make all letters in the csv file become a value to a key called Letters and do likewise to the words too? It sound nice right?. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Steps&lt;/strong&gt;&lt;br&gt;
A). Create a new empty list for the letters.&lt;br&gt;
B). Use a for loop to append all the letters to the new list excluding the "letter" string.&lt;br&gt;
It should be like the below&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import csv

&amp;gt; list = []
with open("Notes.csv") as csv_file:
    data = csv.reader(csv_file)
    for each in data:
        list.append(each)
    Letters = []
    for Char in list:
    If char[0] != "letters":
        Letters.append(char[0]

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The if statement in the above is used to exclude the letter string from the list &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Char = a loop variable &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Char[0] = the item at index 0 of Char variable which is the letter in csv file.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;C). Create another empty list with a variable &lt;br&gt;
words.&lt;br&gt;
D). Use a for loop to append all the word to the words list excluding the "words" string.&lt;br&gt;
Your codes should be like below&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import csv

    list = []
    with open("Notes.csv") as 
    data_file:
    data = csv.reader(data_file)
    for each in data:
        list.append(each)

    Letters = []
    for char in list:
        if char[0] != "letters":
            Letters.append(char[0]

    Words = []
    for word in list:
        if word[0] != "words":
             Words.append(word[0])
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;E). Create an empty dictionary called dict.&lt;br&gt;
F). Add a key called Letters to the empty dict and makes it value to be the Letters list object&lt;br&gt;
G). Add another key called Words to the dict and makes it value to be words list object.&lt;/p&gt;

&lt;p&gt;Your code should be like the following&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--o0b4uDia--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/511dmkzalypeq1rxfhk7.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--o0b4uDia--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/511dmkzalypeq1rxfhk7.jpg" alt="Image description" width="720" height="1092"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Following the above steps, you have completed the task. If you print the dict object you will get what task we want.&lt;/p&gt;

&lt;p&gt;It's result will be:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Md-X1zUq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gawxgnljrojfpke84yp2.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Md-X1zUq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gawxgnljrojfpke84yp2.jpg" alt="Image description" width="720" height="337"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The letters are now the value of Letters and the words is now the value of Words.&lt;/p&gt;




&lt;p&gt;It is very obvious that it took many lines of code to carry out a mini task using the python csv module. &lt;/p&gt;

&lt;p&gt;Another module which python programmers use when the come across csv files is a module called  &lt;strong&gt;Pandas&lt;/strong&gt;.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;&lt;em&gt;Pandas&lt;/em&gt;&lt;/strong&gt; is a software library written for the Python programming language for data manipulation and analysis. In particular, it offers data structures and operations for manipulating numerical tables and time series&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;In our next article,  we will explain more about pandas &lt;/p&gt;

&lt;p&gt;Kindly like, comment and follow !!!!!&lt;/p&gt;




</description>
      <category>programming</category>
      <category>python</category>
      <category>beginners</category>
      <category>react</category>
    </item>
    <item>
      <title>How to Use Python Csv Module</title>
      <dc:creator>Tifey_</dc:creator>
      <pubDate>Sat, 15 Jan 2022 22:19:14 +0000</pubDate>
      <link>https://dev.to/weber/how-to-use-python-csv-module-3elj</link>
      <guid>https://dev.to/weber/how-to-use-python-csv-module-3elj</guid>
      <description>&lt;p&gt;How to Use Csv Module with Csv files in Python &lt;/p&gt;

&lt;p&gt;Csv file which means Comma separated values files. It is a type of file with extension ".csv" which is used as a spreadsheet i.e it is embedded with data in a grid of rows and columns. &lt;/p&gt;

&lt;p&gt;When time comes for you to use a Csv file or a spreadsheet in your program. This article will be of great help as you will be able to open and work with csv files, know what modules are used for csv files, modify and work with csv as if they were they were yours. &lt;/p&gt;

&lt;p&gt;Let's get started!!! &lt;/p&gt;

&lt;p&gt;Python as a high level programming has a pre built module for csv files which is called "csv".&lt;br&gt;
Importing the Csv Module&lt;br&gt;
Since the module is already prebuilt you will only import else you will need to install&lt;br&gt;
        import csv &lt;/p&gt;

&lt;p&gt;Opening the csv file using the with statement.&lt;br&gt;
The with statement is preferred by most Python developers  because it automates the close() function after using its open().&lt;br&gt;
The with statement &lt;/p&gt;

&lt;p&gt;with open ("notes.csv") as csv_file:&lt;br&gt;
    data=csv.reader(csv_file)&lt;br&gt;
open() : is a python function used to open files in a main.py&lt;br&gt;
csv_file : is a variable which stores the file that is been open &lt;br&gt;
data : is a variable assigned to the information extracted from the csv_file after its been accessed by the csv module.&lt;br&gt;
.reader() : is a csv function for reading the content of a opened csv file. &lt;/p&gt;

&lt;p&gt;N:B the reader() is read only. If you print data variable at this stage, it will generate numbers and code which represents the location of the csv file on the computer ROM. &lt;/p&gt;

&lt;p&gt;Converting a csv file to List and Dictionary &lt;/p&gt;

&lt;p&gt;After the file is been read by the csv module. You could start making your modifications. You can convert  it to either a list or dictionary. We will walk you through the two  conversions. &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Converting csv file to a list. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Create an empty stored in a variable.&lt;br&gt;
List  = []&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Loop through the data( variable which you use to store the content of the file when the reader() was used)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Append each item in the data to your new list. &lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Your codes should be in the below format &lt;/p&gt;

&lt;p&gt;When the above code is run. It will outpu the  list of items in the csv file beginning from the first row and convert each row to a list type object. It will output the below &lt;/p&gt;

&lt;p&gt;With this, you can work with your csv files like you do with your list objects.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Converting a csv file to Dictionary.
A dictionary works with its keys and values.
To convert a csv file into a dictionary, we will need a key and value. &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In this article, we will use an item in the file as the key and the other as its value since it is of two columns.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Create an empty dictionary and assign it to a variable.&lt;/li&gt;
&lt;li&gt;Loop through the data&lt;/li&gt;
&lt;li&gt;Add the key and value to the empty dictionary.
Your codes should be in the below format:&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The key used in the above is the item at index 0 on each row of the Csv file and its value is that at index 1.&lt;br&gt;
The following would be its output&lt;/p&gt;

&lt;p&gt;Also with the above out you can also treat your Csv file like that of a dictionary. For example you could modify its value,  its key, change the values and keys, and other dictionary features. &lt;/p&gt;

&lt;p&gt;&amp;lt;|||||||||||-----------------|||||||||||||&amp;gt;&lt;/p&gt;

&lt;p&gt;Now let's advance a little. &lt;br&gt;
How will it be if we could make all letters in the csv file become a value to a key called Letters and do likewise to the words too? It sound nice right?. &lt;/p&gt;

&lt;p&gt;Steps&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Create a new empty list for the letters&lt;/li&gt;
&lt;li&gt;Use a for loop to append all the letters to the new list excluding the "letter" string
It should be like the below &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;**The if statement in the above is used to exclude the letter string from the list &lt;br&gt;
Char = a loop variable &lt;br&gt;
Char[0] = the item at index 0 of Char variable &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Create another empty list with a variable 
words&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Use a for loop to append all the word to the words list excluding the "words" string.&lt;br&gt;
Your codes should be like below&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Create an empty dictionary called dict.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Add a key called Letters to the empty dict and makes it value to be the Letters list object&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Add another key called Words to the dict and makes it value to be words list object.&lt;br&gt;
You code should be like the following&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Following the above steps, you have completed the task. If you print the dict object you will get what task we want.&lt;/p&gt;

&lt;p&gt;It's result will be:&lt;/p&gt;

&lt;p&gt;The letters have now become the value of Letters and the words is now the value of Words.&lt;/p&gt;

&lt;p&gt;It is very obvious that it took many lines of code to carry out a mini task using the python csv module. &lt;/p&gt;

&lt;p&gt;Another module which python programmers use when the come across csv files is a module called  Pandas &lt;/p&gt;

&lt;p&gt;Pandas is a module used to work with csv files. It allows programmers to work with the csv more efficiently. &lt;br&gt;
Using Pandas mores task can be accomplished,  you can get the statistical information of a csv file like the mean, median, mode, standard deviation,  list conversion,  etc using the built functions.&lt;br&gt;
Pandas is occupies a wide range when working with csv files. &lt;/p&gt;

&lt;p&gt;In our next article,  we will explain more about pandas &lt;/p&gt;

&lt;p&gt;Kindly comment !!!!!&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
