Python Forum
parsing text with ply (lex/yacc) tool
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
parsing text with ply (lex/yacc) tool
#1
i need to parse a file which contains some kind of data. i've looked at tutorials but i'm a little bit confused how to apply it to my case.

so the file is going to contain something like this (i'm putting the types of the data):
string number
string
number number number date/time
string
char number number
number number
number number
number number
number number
string
# comment
...
these are the values. each mean something. but as you can see i don't have key-value pairs here. that is why i'm confused how to do it all.

please help!
Reply
#2
If the only keys you have for the values are which line they're on, then you probably can't use a tool. You'll need to open the file, and process it line-by-line into whatever format you want.
Reply
#3
the file consists of, say 1000 such records that have the same structure as above. what about that? can i give a structure as a rule?
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Text parsing Arik 5 381 Mar-11-2024, 03:30 PM
Last Post: Gribouillis
  Modify values in XML file by data from text file (without parsing) Paqqno 2 1,653 Apr-13-2022, 06:02 AM
Last Post: Paqqno
  how to create a tool with tkinter to convert img to text rachidel07 3 2,572 Feb-05-2021, 12:21 PM
Last Post: deanhystad
  Python QGIS tool that replaces layout text labels with attributes from an input table geodenn92 1 2,666 Aug-13-2019, 06:05 AM
Last Post: buran
  parsing complex text file anna 1 2,069 Apr-10-2019, 09:54 PM
Last Post: Larz60+
  Parsing file and get a specific text dds69 4 3,071 Nov-12-2018, 08:06 AM
Last Post: dds69
  Parsing Text file having repeated value key pair using python manussnair 3 3,271 Aug-04-2018, 11:48 PM
Last Post: micseydel
  Parsing and Editing a Structured Text File norsemanGrey 1 2,421 Jul-11-2018, 09:51 PM
Last Post: Larz60+
  Parsing Text File standenman 0 2,338 Jan-24-2018, 11:00 PM
Last Post: standenman
  Text file parsing with python and with a list in grammar pitanga 2 3,220 Aug-31-2017, 02:21 PM
Last Post: pitanga

Forum Jump:

User Panel Messages

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