所以我有一個CSV,我試圖打印出頭6行,然後啓動代碼。我是超級新手。我知道如何跳過下一個(閱讀器)的前6行,但我需要打印前5行,因爲它是標題,然後在數據開始的第8行啓動腳本。所以我認爲這是讀者=之後的某種打印語句,然後可能是下一個(讀者)之後啓動代碼。只是我的理論。打印CSV中的前6行然後開始讀取
import csv
with open('GAT_US_PartReview_2017-06-23.csv', newline='') as f:
reader = csv.reader(f)
for row in reader:
hqline, part_no, part_class, appl_req, appl_count, intr_req,
intr_count, oe_intr, has_oe_intr, has_attr_editor,
part_IMG_req, has_part_img, has_part_img, has_mpcc, warr_req,
warr_txt, warr_pdf, msds_req, has_msds, upc_req, has_upc,
has_unspsc, attr_count, attrval_count, valid_part = row
Supplier Line:,,Gates Rubber - Denver (GAT),,,,,,,,,,,,,,,,,,,,,,
Summary:,,Parts HQ Abbr,,,,,,,,,,,,,,,,,,,,,,
ACCT No:,,40013586,,,,,,,,,,,,,,,,,,,,,,
RecCount:,,10221,,,,,,,,,,,,,,,,,,,,,,
Applicable Date:,,"June 14, 2017 (Wednesday)",,,,,,,,,,,,,,,,,,,,,,
,,,,,,,,,,,,,,,,,,,,,,,,
HQ Line,Part No,Part Class,Appl Req,Appl Count ,Intr Req,Intr Count ,OE Intr Req,Has OE Intr,Has Attr Editor, Has Attr Values,Part IMG Req,Has Part IMG,Has MPCC,Warr Req,Has Warr TXT,Has Warr PDF,MSDS Req,Has MSDS,UPC Req,Has UPC,Has UNSPSC,Attr Count ,AttrVal Count ,Valid Part
GAT,'27210',S,NO,0,YES,1,YES,NO,YES,YES,YES,YES,YES,YES,YES,YES,NO,NO,YES,YES,YES,30,13,YES
GAT,'27211',O,NO,0,YES,1,YES,NO,YES,YES,YES,YES,YES,YES,YES,YES,NO,NO,YES,YES,YES,30,14,YES
GAT,'27212',S,NO,0,YES,1,YES,NO,YES,YES,YES,YES,YES,YES,YES,YES,NO,NO,YES,YES,YES,30,13,YES
GAT,'27213',S,NO,0,YES,1,YES,NO,YES,YES,YES,YES,YES,YES,YES,YES,NO,NO,YES,YES,YES,30,13,YES
GAT,'27220',S,NO,0,YES,2,YES,NO,YES,YES,YES,YES,YES,YES,YES,YES,NO,NO,YES,YES,YES,35,20,YES
GAT,'27221',S,NO,0,YES,2,YES,NO,YES,YES,YES,YES,YES,YES,YES,YES,NO,NO,YES,YES,YES,35,20,YES
而不是圖像..你可以發佈一些示例輸出內容。所以我可以複製它並檢查? – void
發佈...它有點看起來很醜。讓我知道是否有更好的方法。 –