In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-07 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
Most people do not understand the knowledge points of this article "how to traverse python to view csv files", so the editor summarizes the following contents, detailed contents, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "how to traverse python to view csv files" article.
View description
1. If there is Chinese in the comment, you need to add this line, put it on the first line of the file, and specify the utf-8 code.
2. Open the data file in read-only form and store it in the variable csvfile.
Output data using for loops.
Example
# coding=utf-8# if there is Chinese in the comment, you need to add this line, and you need to put it on the first line of the file and specify the utf-8 code. # the purpose is to let the python interpreter save the file according to the encoding you specify, so that the above error will not occur when reading. # Import the csv module import csv that comes with Python # Open the data file as read-only and store it in the variable csvfile # mRNA.csv is the name of the CSV file . / is the path of the mRNA.cs file relative to this Python file csvfile = open ('. / mRNA.csv', 'r') # call the reader () method of csv to save the output in the reader variable reader = csv.reader (csvfile) # use the for loop to output the data for row in reader: # print means printout, there is no extra logic, just want to see the output result # or what is stored in a variable You can use print to print out to view print (row) above is about "how python traverses to view csv documents" the content of this article, I believe we all have a certain understanding, I hope the content shared by the editor will be helpful to you, if you want to know more about the relevant knowledge content, please pay attention to the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.