Is it possible to pass CSV Reader Object As Argument to another Python File ???

bansi mail2bansi at gmail.com
Fri Jan 28 13:33:18 EST 2011


On Jan 28, 9:46 am, bansi <mail2ba... at gmail.com> wrote:
> On Jan 26, 8:31 pm, MRAB <pyt... at mrabarnett.plus.com> wrote:
>
>
>
>
>
> > On 27/01/2011 00:57, bansi wrote:
>
> > > On Jan 26, 6:25 pm, Ethan Furman<et... at stoneleaf.us>  wrote:
> > >> bansi wrote:
>
> > >>   >  First namelookupWrapper.py running under Python 2.6 accept arguments
> > >>   >  from stdin and uses csv reader object to read it i.e.
> > >>   >  r=csv.reader(sys.stdin)
>
> > >>   >  And then it has to pass csv reader object to another python script
> > >>   >  namelookup.py running under Python 2.7 because it uses pyodbc to
> > >>   >  connect to database and iterates thru reader object
>
> > >> Ben Finney wrote:
> > >>> bansi<mail2ba... at gmail.com>  writes:
>
> > >>>> Thanks Chris. Sorry for mis-communicating, the two python scripts are
> > >>>> dependant in a way that namelookupWrapper.py needs to pass csv record
> > >>>> object to another python script
>
> > >>> Why have you structured them that way, though? What constraint is
> > >>> keeping you from doing the work in a single process, where the CSV
> > >>> reader object can be shared?
>
> > >>>> If thats not possible then please let me know how to do the workaround
> > >>>> i didnt understood the import thing and not sure if it helps in my
> > >>>> case
>
> > >>> The problem as you've described it so far is best solved by having a
> > >>> single process accessing the CSV reader object in memory. If that
> > >>> doesn't suit your use case, you'll need to explain why not.
>
> > >> In other words, why can't you use Python 2.7 to accept input and
> > >> generate a csv.reader?
>
> > >> ~Ethan~- Hide quoted text -
>
> > >> - Show quoted text -
>
> > > Ethan,
> > > The python script takes the input from Splunk (http://www.splunk.com/
> > > base/Documentation/) which supports only Python 2.6
> > > So the real constraint is Splunk supports only Python 2.6 .
>
> > > As you know Python 2.6 doesnt support or doesnt have pyodbc install
> > > for Windows  64 bit OS
> > > So i installed Python 2.7 and thereafter pyodbc install for Windows 64
> > > bit OS for Python 2.7
>
> > Have you actually tried Splunk with Python 2.7? It might not work with
> > versions which are earlier than Python 2.6, but that doesn't
> > necessarily mean that it won't work with versions of Python 2 which are
> > later than Python 2.6 (unless the documentation says that it must be
> > Python 2.6).- Hide quoted text -
>
> > - Show quoted text -
>
> Splunk's latest version 4.1.6 doesn't support Python 2.7
> I tried the import trick but it didnt work because the real script
> which runs under Python 2.7 has import pyodbc so it results in
> following error
>
> c:\Splunk\etc\apps\search\bin>splunk cmd python namelookupWrapper.py
> memberId memberName < memberInput.csv
> Traceback (most recent call last):
>   File "namelookupWrapper.py", line 3, in <module>
>     import namelookup
>   File "c:\Splunk\etc\apps\search\bin\namelookup.py", line 7, in
> <module>
>     import pyodbc
> ImportError: DLL load failed: The specified module could not be found.
>
> Please let me know if i am missing something on import. If so please
> provide me with an example- Hide quoted text -
>
> - Show quoted text -

Here are some more details from my earlier posting. Please click the
below link

http://answers.splunk.com/questions/11145/its-getting-mysterious-to-make-the-lookup-script-work



More information about the Python-list mailing list