Python Forum
how to give your data column names based on char position
Thread Rating:
  • 1 Vote(s) - 1 Average
  • 1
  • 2
  • 3
  • 4
  • 5
how to give your data column names based on char position
#1
Hi All

I am very new to python .

I am working with a file with no column header. But the task is to give the file column names based on char positions/substring of data.i have gotten so far to get the first column as below . But i do not know how to actually process the file so it will have column names by the end of it. Please help. Thank you!


<<code>>
with open("/raw10.txt","rb") as f:
... for line in f:
... rec_bytes = int(line[:3])

<<code>>
Reply


Messages In This Thread
how to give your data column names based on char position - by whyme - Oct-27-2017, 05:10 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Returning Column and Row Data From Spreadsheet knight2000 0 477 Oct-22-2023, 07:07 AM
Last Post: knight2000
Sad How to split a String from Text Input into 40 char chunks? lastyle 7 1,218 Aug-01-2023, 09:36 AM
Last Post: Pedroski55
  Database that can compress a column, or all data, automatically? Calab 3 1,252 May-22-2023, 03:25 AM
Last Post: Calab
  Code for pullng all data in a column EmBeck87 5 1,180 Apr-03-2023, 03:43 PM
Last Post: deanhystad
  Grouping Data based on 30% bracket purnima1 4 1,250 Mar-10-2023, 07:38 PM
Last Post: deanhystad
  create new column based on condition arvin 12 2,362 Dec-13-2022, 04:53 PM
Last Post: jefsummers
  How to assign a value to pandas dataframe column rows based on a condition klllmmm 0 877 Sep-08-2022, 06:32 AM
Last Post: klllmmm
  conditionals based on data frame mbrown009 1 925 Aug-12-2022, 08:18 AM
Last Post: Larz60+
  I have written a program that outputs data based on GPS signal kalle 1 1,222 Jul-22-2022, 12:10 AM
Last Post: mcmxl22
Question Change elements of array based on position of input data Cola_Reb 6 2,202 May-13-2022, 12:57 PM
Last Post: Cola_Reb

Forum Jump:

User Panel Messages

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