Extracting data using python
Question:
I have a text file like this
app galaxy store Galaxy Store
app text editor Text Editor
app smartthings SmartThings
app samsung pay Samsung Pay
app pdssgentool PdssGenTool
app pdss-sample pdss-sample
app encodertool EncoderTool
app play store Play Store
app play music Play Music
app keep notes Keep Notes
where the format is like
app(tab)name(tab)name_starting_with_caps
From here I only want to extract the name
part and store it in a list. Can anyone help me how to do that in python. For example list=[galaxy store, text editor, ...]
Answers:
Use csv.reader
with delimiter='t'
:
import csv
with open('yourfile') as f:
csv_reader = csv.reader(f, delimiter='t')
names = [row[1] for row in csv_reader]
I have a text file like this
app galaxy store Galaxy Store
app text editor Text Editor
app smartthings SmartThings
app samsung pay Samsung Pay
app pdssgentool PdssGenTool
app pdss-sample pdss-sample
app encodertool EncoderTool
app play store Play Store
app play music Play Music
app keep notes Keep Notes
where the format is like
app(tab)name(tab)name_starting_with_caps
From here I only want to extract the name
part and store it in a list. Can anyone help me how to do that in python. For example list=[galaxy store, text editor, ...]
Use csv.reader
with delimiter='t'
:
import csv
with open('yourfile') as f:
csv_reader = csv.reader(f, delimiter='t')
names = [row[1] for row in csv_reader]