Why are my files in in my list - os module used with sys argv
Sayth Renshaw
flebber.crue at gmail.com
Tue Apr 19 10:18:11 EDT 2016
On Tuesday, 19 April 2016 23:46:01 UTC+10, Peter Otten wrote:
> Sayth Renshaw wrote:
>
> > Thanks for the insight, after doing a little reading I found this post
> > which uses both argparse and glob and attempts to cover the windows and
> > bash expansion of wildcards,
> > http://breathmintsforpenguins.blogspot.com.au/2013/09/python-crossplatform-handling-of.html
>
> I hope you read the comment section of that page carefully.
> On Linux your script's behaviour will be surprising.
Yes I have gone your way now and am parsing the files, where my data is going will have to wait till after I sleep.
Thanks for the advice.
from pyquery import PyQuery as pq
import pandas as pd
import argparse
# from glob import glob
parser = argparse.ArgumentParser(description=None)
def GetArgs(parser):
"""Parser function using argparse"""
# parser.add_argument('directory', help='directory use',
# action='store', nargs='*')
parser.add_argument("files", nargs="+")
return parser.parse_args()
fileList = GetArgs(parser)
print(fileList.files)
# d = pq(filename='20160319RHIL0_edit.xml')
data = []
attrs = ('id', 'horse')
for items in fileList.files:
d = pq(filename=items)
res = d('nomination')
dataSets = [[res.eq(i).attr(x)
for x in attrs] for i in range(len(res))]
resultList = data.append(dataSets)
frames = pd.DataFrame(resultList)
print(frames)
--------------------------------------------------------------------------
(pyquery)sayth at sayth-E6410:~/Projects/pyquery$ python jqxml.py samples/*.xml
['samples/20160319RHIL0_edit.xml', 'samples/20160402RAND0.xml', 'samples/20160409RAND0.xml', 'samples/20160416RAND0.xml']
Empty DataFrame
Columns: []
Index: []
(pyquery)sayth at sayth-E6410:~/Projects/pyquery$
Thanks
Sayth
More information about the Python-list
mailing list