Re: Import Csv to weka

Peter Reutemann <[email protected]>
Newsgroups gmane.comp.ai.weka
Message-ID <CAHoQ12JefE_SOMTPxWuY7_CwqmsyZK00r4N39m44LVn7m3f-9g@mail.gmail.com>
> I have attached my CSV file here, so if you could see it. It has a few text features.
>
> When I try to import it in Weka, it gives me the following error
>
> could not read object my data.csv, invalid stream header 504C5547

I presume you checked "invoke options dialog" and then clicked on the
"Open" button in the GenericObjectEditor (GOE) window?
When you hover with your mouse over that button it will pop up "Load a
configured object". That's generic functionality of loading (and also
saving) the configuration of an object within the GenericObjectEditor
(you will notice that the Open/Save buttons are present in every
single dialog!). In your case, you were editing the options of the
CSVLoader in the GOE. Weka then tried to load the file that you
pointed it (selecting the file a second time didn't seem odd?) at as
serialized Java object and failed accordingly with the above error
message. Instead, you should have clicked on "OK", accepting the
modifications that you made to the CSVLoader, which then would attempt
to load the CSV file that you already selected earlier.

Anyhow... Weka's CSVLoader does not conform to common standards of
quoting and will fail on your file. Instead, you should install the
(unofficial) csv-commons Weka package:
https://github.com/fracpete/common-csv-weka-package

Once you've restarted Weka, load your CSV file using "Common CSV
files" as file type in the Open dialog (leave "invoke options dialog"
unchecked).

Once loaded, you can then convert any STRING attributes that should be
treated as NOMINAL with the StringToNominal filter.

Finally, save it as ARFF, as you don't want to go through that process again.

Cheers, Peter
-- 
Peter Reutemann
Dept. of Computer Science
University of Waikato, NZ
+64 (7) 858-5174 (office)
+64 (7) 577-5304 (home office)
https://www.cs.waikato.ac.nz/~fracpete/
http://www.data-mining.co.nz/
_______________________________________________
Wekalist mailing list -- [email protected]
Send posts to [email protected]
To unsubscribe send an email to [email protected]
To subscribe, unsubscribe, etc., visit https://list.waikato.ac.nz/postorius/lists/wekalist.list.waikato.ac.nz
List etiquette: http://www.cs.waikato.ac.nz/~ml/weka/mailinglist_etiquette.html
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.