Debug CSV File Open error

Source: Internet
Author: User

Error encountered: _csv. Error:new-line character seen in unquoted field-do do need to open the file in Universal-newline mode?

The error code is as follows:

1 ImportCSV2 ImportSYS3 4Input_file = sys.argv[1]5Output_file = sys.argv[2]6 7With open (Input_file,'R') as Csv_in_file:8With open (Output_file,'W') as Csv_out_file:9FileReader =Csv.reader (csv_in_file)TenFileWriter =Csv.writer (csv_out_file) OneHeader =Next (FileReader) A  -         #Print Header -  the Filewriter.writerow (header) -          forRow_listinchFileReader: -#Printrow_list -Supplier =str (row_list[0]). Strip () +Cost = str (row_list[3]). Strip ("$"). Replace (',',"') -             ifSupplier = ='Supplier X' orFloat (cost) >600.0: +Filewriter.writerow (Row_list)


The above code line 7th is written with open (Input_file, ' RU ') as Csv_in_file: Post-resolution

The main mode of opening the file is incorrect.

' U ' universal newline mode (deprecated)--deprecated in Python3



Debug CSV File Open error

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.