Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #107283

Why are my files in in my list - os module used with sys argv

Newsgroups comp.lang.python
Date 2016-04-18 16:44 -0700
Message-ID <0bce26b1-ad3d-42c4-8f99-08e82d1bce88@googlegroups.com> (permalink)
Subject Why are my files in in my list - os module used with sys argv
From Sayth Renshaw <flebber.crue@gmail.com>

Show all headers | View raw


Hi

Why would it be that my files are not being found in this script?

from pyquery import PyQuery as pq
import pandas as pd
import os
import sys

if len(sys.argv) == 2:
    print("no params")
    sys.exit(1)

dir = sys.argv[1]
mask = sys.argv[2]

files = os.listdir(dir)

fileResult = filter(lambda x: x.endswith(mask), files)

# d = pq(filename='20160319RHIL0_edit.xml')
data = []

for file in fileResult:
    print(file)

for items in fileResult:
    d = pq(filename=items)
    res = d('nomination')
    attrs = ('id', 'horse')
    data = [[res.eq(i).attr(x) for x in attrs] for i in range(len(res))]

    # from nominations
# res = d('nomination')
# nomID = [res.eq(i).attr('id') for i in range(len(res))]
# horseName = [res.eq(i).attr('horse') for i in range(len(res))]

# attrs = ('id', 'horse')

frames = pd.DataFrame(data)
print(frames)


I am running this from the bash prompt as

(pyquery)sayth@sayth-E6410:~/Projects/pyquery$ python jqxml.py samples *.xml

my directory structure

(pyquery)sayth@sayth-E6410:~/Projects/pyquery$ ls -a
.  ..  environment.yml  .git  .gitignore  #jqxml.py#  jqxml.py  samples

and samples contains

(pyquery)sayth@sayth-E6410:~/Projects/pyquery/samples$ ls -a
.   20160319RHIL0_edit.xml  20160409RAND0.xml
..  20160402RAND0.xml       20160416RAND0.xml

yet I get no files out of the print statement.

Ideas?

Sayth

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


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