所以,當我使用CSV作家打印出的參數列表它打印rows.So這樣的事情之間的空行:CSV作家是寫行之間的空行(Python 2.7版)
- 行1
- 空行
- 行2
- 空行
我的問題是什麼我做錯了,讓CSV作家產生的空行。這裏是我的代碼:
row_count = 0
with open(config['LeadImportFilePath']['LeadImportFilePath'] + lead_import_name, 'w') as f:
writer = csv.writer(f)
writer.writerow(config['Headers']['LeadImportHeaders'].split(','))
while row_count <= record_rows:
person_row = [GetCampaignInformation.publisher_id, GetCampaignInformation.source_id, GetPersonInformation.first_name[row_count],
GetPersonInformation.last_name[row_count], GetPersonInformation.GetEmail(), GetPersonInformation.phone[row_count],
GetCampaignInformation.GetIndustry(), GetCampaignInformation.GetJobTitles(), GetPersonInformation.company_name[row_count],
GetPersonInformation.address_1[row_count], GetPersonInformation.address_2[row_count], GetPersonInformation.city[row_count],
GetPersonInformation.state[row_count], GetPersonInformation.zip[row_count], GetCampaignInformation.country, GetCampaignInformation.GetCompanySize(),
lead_create_date, GetCampaignInformation.ReturnAsset(), campaign_id] + GetCampaignInformation.GetCustomQuestion()
writer.writerow(person_row)
row_count += 1
我也收到此錯誤: person_row = [GetCampaignInformation.publisher_id,GetCampaignInformation.source_id,GetPersonInformation.first_name [ROW_COUNT], IndexError:列表索引超出範圍