Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #107332
| X-Received | by 10.66.122.101 with SMTP id lr5mr1913100pab.3.1461075492069; Tue, 19 Apr 2016 07:18:12 -0700 (PDT) |
|---|---|
| X-Received | by 10.50.180.130 with SMTP id do2mr52025igc.9.1461075492031; Tue, 19 Apr 2016 07:18:12 -0700 (PDT) |
| Path | csiph.com!usenet.blueworldhosting.com!feeder01.blueworldhosting.com!news.glorb.com!gy3no6227933igb.0!news-out.google.com!j7ni390igm.0!nntp.google.com!g8no4246755igr.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail |
| Newsgroups | comp.lang.python |
| Date | Tue, 19 Apr 2016 07:18:11 -0700 (PDT) |
| In-Reply-To | <mailman.14.1461073547.30862.python-list@python.org> |
| Complaints-To | groups-abuse@google.com |
| Injection-Info | glegroupsg2000goo.googlegroups.com; posting-host=58.164.13.185; posting-account=5Cd8QAoAAAC6AxpkrISTgUBJ9ktgwNBm |
| NNTP-Posting-Host | 58.164.13.185 |
| References | <0bce26b1-ad3d-42c4-8f99-08e82d1bce88@googlegroups.com> <5715798b$0$1612$c3e8da3$5496439d@news.astraweb.com> <nf4ph0$6gh$1@ger.gmane.org> <mailman.3.1461053808.30862.python-list@python.org> <719abd0a-d3b4-483d-ab77-1989b06f062e@googlegroups.com> <nf5cpq$37a$1@ger.gmane.org> <mailman.14.1461073547.30862.python-list@python.org> |
| User-Agent | G2/1.0 |
| MIME-Version | 1.0 |
| Message-ID | <96dfb79a-697c-47cb-b9d9-690f4f937062@googlegroups.com> (permalink) |
| Subject | Re: Why are my files in in my list - os module used with sys argv |
| From | Sayth Renshaw <flebber.crue@gmail.com> |
| Injection-Date | Tue, 19 Apr 2016 14:18:12 +0000 |
| Content-Type | text/plain; charset=ISO-8859-1 |
| Xref | csiph.com comp.lang.python:107332 |
Show key headers only | View raw
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@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@sayth-E6410:~/Projects/pyquery$
Thanks
Sayth
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Why are my files in in my list - os module used with sys argv Sayth Renshaw <flebber.crue@gmail.com> - 2016-04-18 16:44 -0700
Re: Why are my files in in my list - os module used with sys argv Steven D'Aprano <steve@pearwood.info> - 2016-04-19 10:19 +1000
Re: Why are my files in in my list - os module used with sys argv Peter Otten <__peter__@web.de> - 2016-04-19 10:16 +0200
Re: Why are my files in in my list - os module used with sys argv Sayth Renshaw <flebber.crue@gmail.com> - 2016-04-19 06:21 -0700
Re: Why are my files in in my list - os module used with sys argv Sayth Renshaw <flebber.crue@gmail.com> - 2016-04-19 06:31 -0700
Re: Why are my files in in my list - os module used with sys argv Peter Otten <__peter__@web.de> - 2016-04-19 15:45 +0200
Re: Why are my files in in my list - os module used with sys argv Sayth Renshaw <flebber.crue@gmail.com> - 2016-04-19 07:18 -0700
Re: Why are my files in in my list - os module used with sys argv MRAB <python@mrabarnett.plus.com> - 2016-04-19 02:17 +0100
csiph-web