anaavila / convert-csv-to-arff Goto Github PK
View Code? Open in Web Editor NEWpython program that converts a csv file to arff format
python program that converts a csv file to arff format
Hello,
I've been looked through this code (it is really helpful to understand converting csv to arff format. Thank you so much) over the last two weeks.
While I was thinking about this code, I suddenly had a question about how to convert the arff file to sparse arff format.
I've been thinking about it but am not sure how to implement it based on this code.
Hello,
As of now, the code that author created tries to add single quotes to every value. (FYI, the part of the code is below).
for j in range(0,totalCols):
for i in range(1,totalRows):
allData[i][j] = allData[i][j].lower()
if "\r" in allData[i][j] or '\r' in allData[i][j] or "\n" in allData[i][j] or '\n' in allData[i][j]:
allData[i][j] = allData[i][j].rstrip(os.linesep)
allData[i][j] = allData[i][j].rstrip("\n")
allData[i][j] = allData[i][j].rstrip("\r")
try:
if allData[i][j] == str(float(allData[i][j])) or allData[i][j] == str(int(allData[i][j])):
print
except ValueError as e:
allData[i][j] = "'" + allData[i][j] + "'"
However, I am wondering how to add single quotes to values with space only, such as Bosnia and Herzegovina.
For example,
the return should be like... {Algeria, Argentina, 'Bosnia and Herzegovina', Chile, 'Costa Rica'} .
Please feel free to leave any comment and give help.
Thank you for your help.
Sincerely,
Hello,
Thank you for sharing the code you created.
Like I said in the subject, after I convert csv file to arff file via the code, there is nothing in arff file format when I open it with text editor.
I am wondering if it happens to me only. Would you please help me to solve the issue?
Thank you,
Joon
Hello,
While I was looking at the code that the author created, I had a curious if there is a way to sort the attribute showing unique data of each column in alphabetical order when the csv format converted to arff format. For example, in @Attribute 'Group', it shows {'h','f','b','a','c','d','e','g'}. But, I am wondering how I can make it show as {'a','b','c','d','e','f','g','h'}.
I've tried sort() function in the code, but it did not work and was confused about where to put it.
Please help me to solve this issue.
Thank you!
Where is the ARFF file stored after converting CSV to ARFF ?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.