Python Forum
what will be the best way to find data in txt file?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
what will be the best way to find data in txt file?
#1
Hello,
I have created a "config" file for my code with all kind of data inside , for the code to run and use
the config.txt is :
IP = 10.0.0.5
user = root
pass = MyPass1
FreeData = test
what do I need to do in order to read IP\user\pass\FreeData and use it in the code ?

** will it be better to create a json file? and then get the data from it?

Thanks,
Reply
#2
You can use configparser.

https://docs.python.org/3/library/configparser.html
Reply
#3
Thanks
it's great solution!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  get data from excel and find max/min Timmy94 1 240 Jul-27-2022, 08:23 AM
Last Post: Larz60+
  find some word in text list file and a bit change to them RolanRoll 3 421 Jun-27-2022, 01:36 AM
Last Post: RolanRoll
  Find and delete above a certain line in text file cubangt 12 1,330 Mar-18-2022, 07:49 PM
Last Post: snippsat
Question Help to find the largest int number in a file directory SalzmannNicholas 1 698 Jan-13-2022, 05:22 PM
Last Post: ndc85430
Thumbs Up [SOLVED] Find last occurence of pattern in text file? Winfried 4 1,943 Aug-13-2021, 08:21 PM
Last Post: Winfried
  Find string between two substrings, in a stream of data xbit 1 1,483 May-09-2021, 03:32 PM
Last Post: bowlofred
Music XML File - cannot find the tag ateestructural 1 1,342 Apr-06-2021, 08:26 AM
Last Post: ibreeden
  find the header location in a .bin file without reading the whole file at a time SANJIB 0 1,331 Mar-05-2021, 04:08 PM
Last Post: SANJIB
  Find specific file in an archive tester_V 8 2,322 Feb-13-2021, 06:13 PM
Last Post: tester_V
  xml file creation from an XML file template and data from an excel file naji_python 1 1,292 Dec-21-2020, 03:24 PM
Last Post: Gribouillis

Forum Jump:

User Panel Messages

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