In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly explains the "python loop traversal how to separate data", the article explains the content is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "python loop traversal how to separate data" bar!
Separation instructions
1. Create three lists for storage.
2. The filtered duplicate data. It is used to store the remaining data other than duplicate data. The index (that is, name) used to store all the data to be compared, where the empty name is removed.
Example
# coding=utf-8 # introduction of skip list headers relies on from itertools import islice import csv # for storing duplicate data re_l = [] # for storing data other than duplicated data ntreasl = [] # Index for storing all data to be compared (i.e. name) Remove the empty namevalues = [] # get the namewith open ('. / mRNA.csv', 'r') as f: # skip the list header values_reader = islice (f, 1, None) for value in values_reader: if len (value.split (',', 2) [1])! = 0: values.append (value.split (',') 2) [1]) # classify the data with open ('. / mRNA.csv', 'r') as F1: reader = islice (F1, 1, None) for row in reader: if not row.split (',' 1) [0] in values: n_l.append (row) else: # duplicate data re_l.append (row) # write duplicate data to remRNA.csvwith open ('. / remRNA.csv', 'w') as f2: re_cw = csv.writer (f2) for re_item in re_l: re_cw.writerow (re_item.split (' ) # write duplicate data to nmRNA.csvwith open ('. / nmRNA.csv', 'w') as f3: n_cw = csv.writer (f3) for n_item in nounl: n_cw.writerow (n_item.split (',')) Thank you for your reading The above is the content of "how to separate data with python loop traversal". After the study of this article, I believe you have a deeper understanding of how to separate data with python loop traversal, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
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.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.