Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

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
231,122 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
231,122 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.