Python Forum
Rearrange Columns in a CSV File
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Rearrange Columns in a CSV File
#2
Hi,
The first question before 1-2-3 is about the extra line.
I suspect that you are reading some CRLF from the old file.
In python they call that newline.
You may try to read the row and then do:
row = row[:-1] that takes away the old escape sequence \n

1) Would be simpler to answer if the directory contains only files
that need to be transformed, or other stuff that looks like that.

Paul
Reply


Messages In This Thread
Rearrange Columns in a CSV File - by rjj920 - May-08-2020, 10:06 PM
RE: Rearrange Columns in a CSV File - by DPaul - May-09-2020, 03:26 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Create Choices from .ods file columns cspower 3 679 Dec-28-2023, 09:59 PM
Last Post: deanhystad
  Create csv file with 4 columns for process mining thomaskissas33 3 818 Nov-06-2023, 09:36 PM
Last Post: deanhystad
  How can I rearrange df as the nodes index in pytorch geometric manner? uqlsmey 0 534 Jul-31-2023, 11:28 AM
Last Post: uqlsmey
  Converting a json file to a dataframe with rows and columns eyavuz21 13 4,845 Jan-29-2023, 03:59 PM
Last Post: eyavuz21
  deleting columns in CSV file astral_travel 8 2,512 Nov-26-2022, 09:36 PM
Last Post: astral_travel
  Replace columns indexes reading a XSLX file Larry1888 2 1,025 Nov-18-2022, 10:16 PM
Last Post: Pedroski55
  rows from sql query need to write to a file as columns sjcsvatt 6 2,499 Oct-09-2021, 12:45 AM
Last Post: snippsat
  [Solved] Using readlines to read data file and sum columns Laplace12 4 3,657 Jun-16-2021, 12:46 PM
Last Post: Laplace12
  Python Matplotlib: Create chart for every 4 columns in Excel file JaneTan 2 2,829 Feb-28-2021, 05:02 AM
Last Post: JaneTan
  How to fill parameter with data from multiple columns CSV file greenpine 1 1,695 Dec-21-2020, 06:50 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020