Python Forum
How to conver txt file data to python?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to conver txt file data to python?
#1
Hi there,

I have 7 pieces of data in txt file and I want to import them into python to calculate.

The data show below,

61
1440390.34597081 6962216.63462481 0.0000
1440327.93500638 6962145.92216781 0.0000
1440206.93393606 6962113.13155098 0.0000
1440094.08672081 6962074.93740164 0.0000
1439951.72545697 6962055.83999890 0.0000
1439738.18388930 6962031.53460132 0.0000
1439465.61455256 6962017.64552148 0.0000
1439167.00327313 6962005.49265864 0.0000
1439078.46178356 6962031.53460132 0.0000
1439040.09210964 6962106.70767932 1882.1192
1439037.66658956 6962108.63188806 1882.7731
1439035.24106947 6962110.55544065 1883.0882
1439032.81522131 6962112.47964939 1883.1349
1439030.38970122 6962114.40385814 1883.2880
1439027.96385305 6962116.32741073 1883.4459
1439025.53833297 6962118.25161947 1883.5632
1439021.90973130 6962120.93206032 1883.5961
END
62
1401896.70576663 6929883.83610156 0.0000
1401995.67407264 6929869.50804622 0.0000
END
63
1397120.90921588 6925766.44407390 0.0000
1397182.51342338 6925687.67257789 0.0000
END
64
1397573.55266756 6925836.10174298 0.0000
1397653.72704789 6925776.33513023 322.3153
END
65
1391132.23877855 6922267.91957490 0.0000
1391104.01180089 6922171.98603973 845.1704
END
66
1440456.51841064 6962291.60921240 0.0000
1440390.34597081 6962216.63462481 0.0000
END
67
1440456.51841064 6962291.60921240 0.0000
1440410.49291214 6962333.03924765 0.0000
1440386.80135848 6962362.84463423 0.0000
END

Each piece of data start with it serial number(from 61 to 67), and end up with "END". There are three columns in each piece of data. Each column means data points on each XYZ coordinate on three-dimensional. I want to convert them into dictionary(or maybe there is another easier way but I don't know). How could I make it?

The result I want is that when I type in serial number(ex. 62) and I could call that piece data out.

like this :

62
1401896.70576663 6929883.83610156 0.0000
1401995.67407264 6929869.50804622 0.0000

Thanks!
Reply
#2
What have you tried? This forum is focused on education, so we need to see your attempt. You should also tell us exactly what about your attempt is wrong, and clearly explain what exactly is blocking you from moving forward yourself with this project.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to modify python script to append data on file using sql server 2019? ahmedbarbary 1 1,175 Aug-03-2022, 06:03 AM
Last Post: Pedroski55
  xml file creation from an XML file template and data from an excel file naji_python 1 2,068 Dec-21-2020, 03:24 PM
Last Post: Gribouillis
  Databricks, Python Notebook Data file use issue khalid2200 0 1,734 Nov-25-2020, 03:36 AM
Last Post: khalid2200
  saving data from text file to CSV file in python having delimiter as space K11 1 2,353 Sep-11-2020, 06:28 AM
Last Post: bowlofred
  Importing data from a text file into an SQLite database with Python macieju1974 7 4,011 Jun-29-2020, 08:51 PM
Last Post: buran
  How to save CSV file data into the Azure Data Lake Storage Gen2 table? Mangesh121 0 2,079 Jun-26-2020, 11:59 AM
Last Post: Mangesh121
  How to get Data-Taken For a Video file using Python ramprasad1211 1 1,862 Apr-28-2020, 08:48 AM
Last Post: ndc85430
  Function to skip meta data in a .csv file using Python ajgardev 1 2,471 Jul-22-2018, 12:53 PM
Last Post: Larz60+
  Storing Python data output as a Netcdf file Lightning1800 1 2,605 May-16-2018, 10:14 PM
Last Post: micseydel
  convert text file data to HTML table in python Tirumal 5 12,405 Dec-29-2017, 04:44 PM
Last Post: buran

Forum Jump:

User Panel Messages

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