Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript

Does anyone know of an app. to convert Text files

Good afternoon people of the world,

Would anyone know of an app, that could convert good old txt files to either Json or Csv. Hopefully a free app. I have been browsing the old web and can't really find a thing to help.

Many Thanks

2 Answers

Steven Parker
Steven Parker
215,940 Points

This is an odd request since both JSON and CSV are text formats. So it sounds like you just need to apply delimiters for the format which can probably be done using a search-and-replace function of a text editor.

But you must also consider the content of your original files. JSON involves key/value pairs, is that what your file contains?

They would end up key/value pairs so to speak, txt file looks like:

yyyy mm tmax tmin af rain sun degC degC days mm hours 1964 9 20.5 8.8 0 37.4 --- 1964 10 13.6 4.2 5 77.8 --- 1964 11 11.8 4.7 3 45.5 --- 1964 12 7.7 0.1 17 65.1 ---

see where i am trying to go ????

Steven Parker
Steven Parker
215,940 Points

That's a typical single line? I don't see key/value pairs there. But it looks like it could easily be converted to CSV just by replacing spaces with commas.