Ian Milburn
Ian Milburn

Reputation: 1

converting a csv file to arff file using weka converter, but it is not counting enough columns

For a university project I am trying to convert a CSV to ARFF using Weka's CSVLoader from the GUI. In the options I set the enclosure character for strings to be ", although there are no quotes in my file. I get the following error:

weka.core.converters.CSVLoaderfailed to lead Reason: wrong number of values. Read 20, expected 22, read Token[EOL], line 3215

I can't see how its only reading 20 columns when there are 22

Here is line 3214:

7030878916,https://cleveland.craigslist.org/apa/d/cleveland-your-next-home-awaits-at/7030878916.html,cleveland,https://cleveland.craigslist.org,825,apartment,1100,2,2,0,0,1,0,0,0,?,?,yes,"Green grass and a brick facade welcome you to Moreland Manor Apartments. Our affordable Shaker Heights, OH, apartments are equipped with everything you need to live well in the Lee-Van Aken area.  Available in one and two bedroom suites, the apartments for rent at Moreland Manor are quiet and secluded for your comfort. For further peace of mind, we feature secure-access entry. Inside each of our homes you will find a spacious floor plan with modern kitchen. We supply a refrigerator, dishwasher, and range.",41.4714,-81.5839,oh

Here is line 3215:

7046602013,https://cleveland.craigslist.org/apa/d/lakewood-west-lakewood-upstairs-2-bdrm/7046602013.html,cleveland,https://cleveland.craigslist.org,1100,apartment,900,2,1,0,0,1,0,0,0,w/d hookups,?,yes,2 bedroom upstairs apartment in West Lakewood with updated kitchen and bathroom including central air and dishwasher. 7 minute walk to both Downtown Lakewood and Lakewood Park. Large balcony. Hookups for washer and dryer in basement. Short term lease with opportunity for extension. First month's rent and deposit due upon signing of lease.,41.4902,-81.8058,oh

Here is line 3216:

7029945333,https://cleveland.craigslist.org/apa/d/euclid-2-bedroom-15-bathroom-suite-on/7029945333.html,cleveland,https://cleveland.craigslist.org,859,apartment,1000,2,1.5,0,0,1,0,0,0,laundry in bldg,off-street parking,yes,"At GreenRidge on Euclid we go out of our way to make you feel at home by encouraging you to showcase your individuality, Choose from six different 1 and 2 bedroom floor plans and personalize your apartment with your choice of vertical blind accents, accent paint colors, and carpet colors!  Greenridge on Euclid can be found on Euclid Avenue with access to Route 2, I-90 & I-271. Located just a few minutes from downtown Cleveland and the shopping and dining areas of Cleveland's East Side.  Contact us via phone about apartment 2b today! Call Paul at   show contact info .  Available Monday - Friday 8:00 am - 5:00 pm and Saturday by Appointment.  All apartments feature eight inches of solid concrete between each suite these apartments are built to keep sounds at home, spacious closets with full length mirrored doors and most have both dining rooms and eat-in kitchens. Luxurious wall to wall carpeting complements the living, dining and bedrooms while the kitchens & bathrooms are furnished with ceramic or no wax floors. Standard equipment for the kitchens includes a gas range with a sealed cooktop and self-cleaning oven, energy saving two door frost free refrigerator/freezer, energy star dishwasher, garbage disposal, range hood exhaust fan, and a stainless steel sink with extendable spout faucet. Wood cabinets with easy clean butcher block counter tops and a pantry complete the kitchen.  It all adds up to the smart alternative to downtown living, the apartment you deserve and a lifestyle you can afford!  At Greenridge on Euclid you'll enjoy: ,Bigger Suites,Environmentally friendly LED light fixtures,Free Heat & All Utilities (except electricity, phone & cable),Every room has at least one power outlet with a built in USB charger.,Individual Control of Heat & A/C by Programmable Thermostats,On-site Health Club & Free Wi-Fi* (coming soon),In-suite thermostat  to control heat and central air conditioning,Emergency Maintenance 24/7,Bright, Clean Laundry Room open 24/7,Package Delivery Acceptance,Smoke-Free Common Areas,An Intercom System that Connects Visitors to Your Cell Phone,24/7 Interior and Exterior Video Surveillance  http://www.greenridgeoneuclid.com https://www.facebook.com/Greenridge-on-Euclid-533365966869525/ https://twitter.com/GreenridgeEuc",41.6025,-81.5258,oh

Any Ideas? I can't find an error

All asci characters above 127 have been removed, and all blank spaces have been filled in with ?, but it has not changed how many columns have been found on this line

Upvotes: 0

Views: 64

Answers (1)

fracpete
fracpete

Reputation: 2608

The problem is in the single quotes in your text cells. Weka's CSVLoader is sensitive to escaping such characters.

In order to convert it to a format that Weka's native CSVLoader can process I did the following:

  1. The input data
7030878916,https://cleveland.craigslist.org/apa/d/cleveland-your-next-home-awaits-at/7030878916.html,cleveland,https://cleveland.craigslist.org,825,apartment,1100,2,2,0,0,1,0,0,0,?,?,yes,"Green grass and a brick facade welcome you to Moreland Manor Apartments. Our affordable Shaker Heights, OH, apartments are equipped with everything you need to live well in the Lee-Van Aken area. Available in one and two bedroom suites, the apartments for rent at Moreland Manor are quiet and secluded for your comfort. For further peace of mind, we feature secure-access entry. Inside each of our homes you will find a spacious floor plan with modern kitchen. We supply a refrigerator, dishwasher, and range.",41.4714,-81.5839,oh
7046602013,https://cleveland.craigslist.org/apa/d/lakewood-west-lakewood-upstairs-2-bdrm/7046602013.html,cleveland,https://cleveland.craigslist.org,1100,apartment,900,2,1,0,0,1,0,0,0,w/d hookups,?,yes,2 bedroom upstairs apartment in West Lakewood with updated kitchen and bathroom including central air and dishwasher. 7 minute walk to both Downtown Lakewood and Lakewood Park. Large balcony. Hookups for washer and dryer in basement. Short term lease with opportunity for extension. First month's rent and deposit due upon signing of lease.,41.4902,-81.8058,oh
7029945333,https://cleveland.craigslist.org/apa/d/euclid-2-bedroom-15-bathroom-suite-on/7029945333.html,cleveland,https://cleveland.craigslist.org,859,apartment,1000,2,1.5,0,0,1,0,0,0,laundry in bldg,off-street parking,yes,"At GreenRidge on Euclid we go out of our way to make you feel at home by encouraging you to showcase your individuality, Choose from six different 1 and 2 bedroom floor plans and personalize your apartment with your choice of vertical blind accents, accent paint colors, and carpet colors! Greenridge on Euclid can be found on Euclid Avenue with access to Route 2, I-90 & I-271. Located just a few minutes from downtown Cleveland and the shopping and dining areas of Cleveland's East Side. Contact us via phone about apartment 2b today! Call Paul at show contact info . Available Monday - Friday 8:00 am - 5:00 pm and Saturday by Appointment. All apartments feature eight inches of solid concrete between each suite these apartments are built to keep sounds at home, spacious closets with full length mirrored doors and most have both dining rooms and eat-in kitchens. Luxurious wall to wall carpeting complements the living, dining and bedrooms while the kitchens & bathrooms are furnished with ceramic or no wax floors. Standard equipment for the kitchens includes a gas range with a sealed cooktop and self-cleaning oven, energy saving two door frost free refrigerator/freezer, energy star dishwasher, garbage disposal, range hood exhaust fan, and a stainless steel sink with extendable spout faucet. Wood cabinets with easy clean butcher block counter tops and a pantry complete the kitchen. It all adds up to the smart alternative to downtown living, the apartment you deserve and a lifestyle you can afford! At Greenridge on Euclid you'll enjoy: ,Bigger Suites,Environmentally friendly LED light fixtures,Free Heat & All Utilities (except electricity, phone & cable),Every room has at least one power outlet with a built in USB charger.,Individual Control of Heat & A/C by Programmable Thermostats,On-site Health Club & Free Wi-Fi* (coming soon),In-suite thermostat to control heat and central air conditioning,Emergency Maintenance 24/7,Bright, Clean Laundry Room open 24/7,Package Delivery Acceptance,Smoke-Free Common Areas,An Intercom System that Connects Visitors to Your Cell Phone,24/7 Interior and Exterior Video Surveillance http://www.greenridgeoneuclid.com https://www.facebook.com/Greenridge-on-Euclid-533365966869525/ https://twitter.com/GreenridgeEuc",41.6025,-81.5258,oh
  1. load the above CSV file with the Common CSV loader (Weka package project page) in the Weka Explorer. I also checked the noHeader option.

  2. save the data as CSV file (i.e., using Weka's native CSVSaver)

This will give you the following content:

att-1,att-2,att-3,att-4,att-5,att-6,att-7,att-8,att-9,att-10,att-11,att-12,att-13,att-14,att-15,att-16,att-17,att-18,att-19,att-20,att-21,att-22
7030878916,https://cleveland.craigslist.org/apa/d/cleveland-your-next-home-awaits-at/7030878916.html,cleveland,https://cleveland.craigslist.org,825,apartment,1100,2,2,0,0,1,0,0,0,'?','?',yes,'Green grass and a brick facade welcome you to Moreland Manor Apartments. Our affordable Shaker Heights, OH, apartments are equipped with everything you need to live well in the Lee-Van Aken area. Available in one and two bedroom suites, the apartments for rent at Moreland Manor are quiet and secluded for your comfort. For further peace of mind, we feature secure-access entry. Inside each of our homes you will find a spacious floor plan with modern kitchen. We supply a refrigerator, dishwasher, and range.',41.4714,-81.5839,oh
7046602013,https://cleveland.craigslist.org/apa/d/lakewood-west-lakewood-upstairs-2-bdrm/7046602013.html,cleveland,https://cleveland.craigslist.org,1100,apartment,900,2,1,0,0,1,0,0,0,'w/d hookups','?',yes,'2 bedroom upstairs apartment in West Lakewood with updated kitchen and bathroom including central air and dishwasher. 7 minute walk to both Downtown Lakewood and Lakewood Park. Large balcony. Hookups for washer and dryer in basement. Short term lease with opportunity for extension. First month\'s rent and deposit due upon signing of lease.',41.4902,-81.8058,oh
7029945333,https://cleveland.craigslist.org/apa/d/euclid-2-bedroom-15-bathroom-suite-on/7029945333.html,cleveland,https://cleveland.craigslist.org,859,apartment,1000,2,1.5,0,0,1,0,0,0,'laundry in bldg','off-street parking',yes,'At GreenRidge on Euclid we go out of our way to make you feel at home by encouraging you to showcase your individuality, Choose from six different 1 and 2 bedroom floor plans and personalize your apartment with your choice of vertical blind accents, accent paint colors, and carpet colors! Greenridge on Euclid can be found on Euclid Avenue with access to Route 2, I-90 & I-271. Located just a few minutes from downtown Cleveland and the shopping and dining areas of Cleveland\'s East Side. Contact us via phone about apartment 2b today! Call Paul at show contact info . Available Monday - Friday 8:00 am - 5:00 pm and Saturday by Appointment. All apartments feature eight inches of solid concrete between each suite these apartments are built to keep sounds at home, spacious closets with full length mirrored doors and most have both dining rooms and eat-in kitchens. Luxurious wall to wall carpeting complements the living, dining and bedrooms while the kitchens & bathrooms are furnished with ceramic or no wax floors. Standard equipment for the kitchens includes a gas range with a sealed cooktop and self-cleaning oven, energy saving two door frost free refrigerator/freezer, energy star dishwasher, garbage disposal, range hood exhaust fan, and a stainless steel sink with extendable spout faucet. Wood cabinets with easy clean butcher block counter tops and a pantry complete the kitchen. It all adds up to the smart alternative to downtown living, the apartment you deserve and a lifestyle you can afford! At Greenridge on Euclid you\'ll enjoy: ,Bigger Suites,Environmentally friendly LED light fixtures,Free Heat & All Utilities (except electricity, phone & cable),Every room has at least one power outlet with a built in USB charger.,Individual Control of Heat & A/C by Programmable Thermostats,On-site Health Club & Free Wi-Fi* (coming soon),In-suite thermostat to control heat and central air conditioning,Emergency Maintenance 24/7,Bright, Clean Laundry Room open 24/7,Package Delivery Acceptance,Smoke-Free Common Areas,An Intercom System that Connects Visitors to Your Cell Phone,24/7 Interior and Exterior Video Surveillance http://www.greenridgeoneuclid.com https://www.facebook.com/Greenridge-on-Euclid-533365966869525/ https://twitter.com/GreenridgeEuc',41.6025,-81.5258,oh

When comparing the two, you will see that Weka uses single quotes for text cells and escapes single quotes within text cells with a backslash.

My advice is not to use the Weka CSVLoader, but the one from the Common CSV Weka package. The latter handles common CSV dialects better than Weka.

Upvotes: 1

Related Questions