Python Forum
Converting .txt to .csv file
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Converting .txt to .csv file
#1
Hi,

I'm needing a little help getting a text/tab delimited file imported in with python. I think I'm missing how to import the columns... This is what my text file looks like. I was thinking it was a tab delimited file but when I import it in from out Gerber cutters it comes in as a text file. So maybe I'm wrong somewhere there...

[Image: bsgmx0t.jpg]

I run the code below to try and convert it to .csv so I can convert it to .xlsx

import pandas as pd
 
save_path = "C:/Users/vhubb/Documents/Python Scripts"
 
in_filename = os.path.join(save_path,'mytxt.txt')
out_filename = os.path.join(save_path,'Output.csv')
 
df = pd.read_csv(in_filename, sep=";")
df.to_csv(out_filename, index=False)
But when I run this code it converts all columns into one

[Image: FSMvYQ9.jpg]

I'm thinking it's because of this part of the code with the ;

df = pd.read_csv(in_filename, sep=";")
Or am I going completely wrong with what I'm thinking. I'm trying to import this text file with specific columns into a .xlsx file that I created with python. The same .xlsx file (Cutter A - Marker Report.xlsx) that I mentioned in an earlier post. I was thinking I needed to convert it to a .csv file that I would then need to convert to a .xlsx file. From there I was going to figure out how to import it in to the correct columns for the Cutter A - Marker Report.xlsx that I have created.

[Image: Z5ztH61.jpg]

Thanks,
Veronica
Reply


Messages In This Thread
Converting .txt to .csv file - by SunWers - Jan-01-2021, 06:29 AM
RE: Converting .txt to .csv file - by palladium - Jan-01-2021, 06:52 AM
RE: Converting .txt to .csv file - by SunWers - Jan-01-2021, 07:31 AM
RE: Converting .txt to .csv file - by palladium - Jan-01-2021, 07:53 AM
RE: Converting .txt to .csv file - by SunWers - Jan-01-2021, 08:04 AM
RE: Converting .txt to .csv file - by buran - Jan-01-2021, 07:27 AM
RE: Converting .txt to .csv file - by SunWers - Jan-01-2021, 07:39 AM
RE: Converting .txt to .csv file - by buran - Jan-01-2021, 07:41 AM
RE: Converting .txt to .csv file - by SunWers - Jan-01-2021, 07:48 AM
RE: Converting .txt to .csv file - by palladium - Jan-01-2021, 07:56 AM
RE: Converting .txt to .csv file - by buran - Jan-01-2021, 07:54 AM
RE: Converting .txt to .csv file - by SunWers - Jan-01-2021, 07:56 AM
RE: Converting .txt to .csv file - by buran - Jan-01-2021, 08:39 AM
RE: Converting .txt to .csv file - by SunWers - Jan-02-2021, 01:22 AM
RE: Converting .txt to .csv file - by stevenroger - Jan-01-2021, 09:55 AM
RE: Converting .txt to .csv file - by buran - Jan-01-2021, 03:04 PM
RE: Converting .txt to .csv file - by buran - Jan-02-2021, 03:24 AM
RE: Converting .txt to .csv file - by Pedroski55 - Jan-02-2021, 05:03 AM
RE: Converting .txt to .csv file - by caleb_cruze - Jan-04-2021, 01:10 PM
RE: Converting .txt to .csv file - by buran - Jan-04-2021, 01:12 PM
RE: Converting .txt to .csv file - by pruthvi666 - Jan-19-2024, 10:36 AM
RE: Converting .txt to .csv file - by Larz60+ - Jan-20-2024, 10:03 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Converting a json file to a dataframe with rows and columns eyavuz21 13 4,812 Jan-29-2023, 03:59 PM
Last Post: eyavuz21
  [split] Help- converting file with pyton script eltomassito 6 3,340 Jul-02-2021, 05:29 PM
Last Post: snippsat
  Help- converting file with pyton script grinleon 3 2,532 Sep-23-2020, 11:48 AM
Last Post: grinleon

Forum Jump:

User Panel Messages

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