Skip to main content

  The python script is (python 2.7) :

 
 import urllib mysock = urllib.urlopen("........") outcsv = mysock.read() oFile = open("c:\\temp\\example.csv",'wb') oFile.write(outcsv) oFile.close
 

  The problem with this script is that when I run it I do not get the right rows count of the csv file.

 

  To explain the script a bit better, with this startup python script I am calling a csv file in internet. Then I just want the script to save it in my C drive. After that a reader in FME will read to start another process.

 

  For the moment I do it manually (copy and paste my link into a browser, recuperate the csv file and save it to the right place in my C drive) without using this script and I am getting the right numbers of entries.

 

  I do not understand why I am getting different numbers of rows doing it manually and automatically? Does somebody have an idea?

 

  Thanks for your help.

Hi,

 

 

if you're using FME2013, you can simply give the URL to the CSV reader directly, rather than the filename.

 

 

That way you don't have to use the startup script at all.

 

 

David
Alternatively, you could replace the startup script with a PythonCreator that downloads and parses the CSV into FME features without having to write it to disk first.

 

 

Take a look at the sample code here for some ideas.

 

 

David
Hi,

 

 

Thanks a lot for your reply.

 

 

Yes I am using FME 2013. I tried to paste my URL to the CSV reader directly and it worked. The problem which is coming next is this error message I get:

 

 

"Unexpected Input  : During translation, some features were read that did not match a reader feature type in the workspace. This can happen if the reader dataset is changed, or a reader feature type removed or renamed. "

 

 And as I read the log file in the Features read Summary, all my csv fils has been read but no features has been written.

 

 

Do you have an idea of the problem?

 

 

OK as I copy and paste my complete process without the reader in a blank workspace and I recreate a new reader it worked.

 

 

Thanks a lot!

 

Arnaud

 


It seems like you too have discovered that the CSV reader is indeed a little fussy about the schema: If you create a CSV reader and the input format changes sligthly later on, you may get these kinds of errors.

 

 

Good to hear that you found a solution.

 

 

David

Reply