在python中写入csv文件时如何跳过列

在python中写入csv文件时如何跳过列,python,csv,Python,Csv,如果有人问这个问题,很抱歉,但是在写入csv文件时是否可以跳过一列 以下是我的代码: with open("list.csv","r") as f: reader2 = csv.reader(f) for row in reader2: url = 'http://peopleus.intelius.com/results.php?ReportType=33&qi=0&qk=10&qp='+row req = urllib.

如果有人问这个问题,很抱歉,但是在写入csv文件时是否可以跳过一列

以下是我的代码:

with open("list.csv","r") as f:
    reader2 = csv.reader(f)
    for row in reader2:
        url = 'http://peopleus.intelius.com/results.php?ReportType=33&qi=0&qk=10&qp='+row
        req = urllib.request.Request(url)
        response = urllib.request.urlopen(req)
        html = response.read()
        retrieved_name = b'class="singleName">(.*?)<\/h1'
        retrieved_number = b'<div\sclass="phone">(.*?)<\/div'
        retrieved_nothing = b"(Sorry\swe\scouldn\\'t\sfind\sany\sresults)"
        if re.search(retrieved_nothing,html):
            noth = re.search(retrieved_nothing.decode('utf-8'),html.decode('utf-8')).group(1)
            add_list(phone_data, noth)
        else:
            if re.search(retrieved_name,html):
                name_found = re.search(retrieved_name.decode('utf-8'),html.decode('utf-8')).group(1)
            else:
                name_found = "No name found on peopleus.intelius.com"
            if re.search(retrieved_number,html):
                number_found = re.search(retrieved_number.decode('utf-8'),html.decode('utf-8')).group(1)
            else:
                number_found = "No number found on peopleus.intelius.com"
            add_list(phone_data, name_found, number_found)
        with open('column_skip.csv','a+', newline='') as mess:
            writ = csv.writer(mess, dialect='excel')
            writ.writerow(phone_data[-1])
        time.sleep(10)
打开(“list.csv”、“r”)作为f:
reader2=csv.reader(f)
对于reader2中的行:
url='1〕http://peopleus.intelius.com/results.php?ReportType=33&qi=0&qk=10&qp=“+行
req=urllib.request.request(url)
response=urllib.request.urlopen(req)
html=response.read()

检索到的_name=b'class=“singleName”>(.*)是的,不要使用csv.writer方法并将其作为简单的文件写入操作写入:

  `file_path ='your_csv_file.csv'
   with open(file_path, 'w') as fp:
       #following are the data you want to write to csv
       fp.write("%s, %s, %s" % ('Name of col1', 'col2', 'col4'))
       fp.write("\n")`
我希望这有帮助…

阵列切片是您的朋友。