Python Forum
How can I parse a text file?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How can I parse a text file?
#5
Thank you very much!

Here you see that I have just coded  Smile
def command_save(command):
   var = subprocess.check_output(command.split(), universal_newlines=True)
   output = open('scanning.txt', 'w')
   print(var, file=output)
   output.close()

def scannig():
   var = subprocess.check_output(['sudo', 'iwlist', 'scanning'], universal_newlines=True)
   output = open('scanning.txt', 'w')
   print(var, file=output)
   output.close()

address = []
channel = []
essid = []
f = open('scanning.txt', 'r').readlines()
for x in f:
   if "Address" in x:
       address.append(x)


for x in f:
   if "Channel" in x:
       channel.append(x)

for x in f:
   if "ESSID" in x:
       essid.append(x)

address = ''.join(address)
channel = ''.join(channel)
essid = ''.join(essid)

address = address.split()
channel = channel.split()
essid = essid.split()
Now I cannot join address, channel, essid together them.
Reply


Messages In This Thread
How can I parse a text file? - by Mike Ru - May-30-2017, 08:24 PM
RE: How can I parse a text file? - by snippsat - May-30-2017, 09:17 PM
RE: How can I parse a text file? - by Mike Ru - May-30-2017, 09:30 PM
RE: How can I parse a text file? - by snippsat - May-30-2017, 10:15 PM
RE: How can I parse a text file? - by Mike Ru - May-30-2017, 10:57 PM
RE: How can I parse a text file? - by volcano63 - May-31-2017, 12:10 PM
RE: How can I parse a text file? - by AussieSusan - May-31-2017, 03:06 AM
RE: How can I parse a text file? - by wavic - May-31-2017, 06:16 AM
RE: How can I parse a text file? - by DeaD_EyE - May-31-2017, 12:19 PM
RE: How can I parse a text file? - by volcano63 - May-31-2017, 12:29 PM
RE: How can I parse a text file? - by DeaD_EyE - May-31-2017, 12:45 PM
RE: How can I parse a text file? - by Mike Ru - May-31-2017, 06:22 PM
RE: How can I parse a text file? - by nilamo - May-31-2017, 07:27 PM
RE: How can I parse a text file? - by Mike Ru - May-31-2017, 07:39 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  parse json field from csv file lebossejames 4 778 Nov-14-2023, 11:34 PM
Last Post: snippsat
  parse/read from file seperated by dots giovanne 5 1,138 Jun-26-2023, 12:26 PM
Last Post: DeaD_EyE
Thumbs Up Need to compare the Excel file name with a directory text file. veeran1991 1 1,153 Dec-15-2022, 04:32 PM
Last Post: Larz60+
  Trying to parse only 3 key values from json file cubangt 8 3,533 Jul-16-2022, 02:05 PM
Last Post: deanhystad
  Modify values in XML file by data from text file (without parsing) Paqqno 2 1,726 Apr-13-2022, 06:02 AM
Last Post: Paqqno
  Converted Pipe Delimited text file to CSV file atomxkai 4 7,051 Feb-11-2022, 12:38 AM
Last Post: atomxkai
  [split] How to convert the CSV text file into a txt file Pinto94 5 3,406 Dec-23-2020, 08:04 AM
Last Post: ndc85430
  Saving text file with a click: valueerror i/o operation on closed file vizier87 5 4,454 Nov-16-2020, 07:56 AM
Last Post: Gribouillis
  saving data from text file to CSV file in python having delimiter as space K11 1 2,425 Sep-11-2020, 06:28 AM
Last Post: bowlofred
  Web Form to Python Script to Text File to zip file to web wfsteadman 1 2,158 Aug-09-2020, 02:12 PM
Last Post: snippsat

Forum Jump:

User Panel Messages

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