Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Text editing with python
#1
Hi, I have a *.txt 3d scan file in the form of x,y,z...

-43.9017 58.4327 8.0448 0.5321
-43.9031 58.4574 8.0457 0.4800
-43.9247 58.4600 8.0505 0.5794
-43.8825 58.4828 8.0390 0.5164

The problem is that the file is way too big and needs some culling ... ie it has about 2055 million point and in order for a program to read it it needs to be less than 2000 million or even less. I am a beginner in python and it shouldn't be hard but the idea is to open the file through python, delete every 50th row and save in another location. In another situation i would have sat it through and solved it myself but because it critical for my job i don't have the luxury of time.

Thanks in advance for your help.
Reply
#2
You can read it and process it line by line:

with open('big_file.txt', 'r') as f:
    for line in f:
        # do something
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Editing text between two string from different lines Paqqno 1 1,287 Apr-06-2022, 10:34 PM
Last Post: BashBedlam
  Editing a txt document using python duckredbeard 3 2,412 Sep-24-2020, 02:38 AM
Last Post: duckredbeard
  Parsing and Editing a Structured Text File norsemanGrey 1 2,387 Jul-11-2018, 09:51 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