A buddy of mine is trying to convert a CSV file full of data into something called a tcsv file for use with a service he is developing.
I could barely find anything on TCSV files except for here This seems to describe what makes a TCSV file.
So my question is, would I be able to use python, (or JS, as in the example) in order to convert a csv to tcsv file? Is this something I can do with code? If someone could explain what a tcsv file is and how it's used that would help, thank you!
Tell your buddy the whole point of .csv files is that they are unstructured apart from the commas separating fields and the newlines demarcating new records.
A clue to how useful the .tscv file extension may be at some future point in time is in the title given by the person on github (your link) experimenting with them: "Simpler, streamable, more compact, easier to read, gzip friendlier than JSON. Hopefully..."
If your buddy insists on a more human-readable form of data he can transform them pretty easily into xml, or even JSON, and he'll very likely have more joy than following that github post's apparently aborted experiment.
That tcsv stuff doesn't look easier to read than well-formatted JSON to me. Though xml seems to win hands-down if written with readability in mind.
See http://json.org/example.html.
Related
The R rgl package exports an HTML widget with the rglwidget() function, built using the htmlwidgets package. Often the data for this widget is quite large, and Pandoc and webshot2 choke on it.
I would like to try compressing the data when the HTML page is created, and uncompressing it in Javascript before display. I can see that there's a Javascript package pako that appears to do what I want, and it can be "browserified", but I can't see how to make it available to rglwidget(). Can anyone describe what's necessary?
Edited to add some more detail in response to a comment: This needs to happen on the server (or actually, even before the file gets to the server). htmlwidgets produces output in a Markdown document that is converted to HTML by Pandoc, and that step is failing because Pandoc chokes on the large JSON datasets. I'm not sure if it's just the size, or the complexity (I think Pandoc parses the JSON, and appears to blow up to a huge memory footprint before it crashes). I'm hoping that by using a base64 blob Pandoc will handle it better. webshot2 also has problems that may be the same.
2nd Edit: I've got some evidence that it's the size that matters, not the complexity. I used base64 encoding on the JSON to make it simpler (just one long string), but 33% bigger, and things were worse. So I'm back to thinking that compression would help.
Intro
Hi, I was looking for answer in the whole Internet (in some way I kind of feel that I know every question in Stack Overflow), but the answers were never appropriate to what I'm looking for. I was trying to avoid posting question here, but situation forced me to do this.
Sorry if the answer is simpler than I think.
I'm in the middle of building my first app in Electron using JavaScript. I think that I should describe it in few words, so flam:ngo™ (which is projects name) should work like this:
User will upload two files:
file with tables (like XLSX or DOC)
file with data and blank spaces (which will be used as a template)
App will import from tables.
Now app should let user choose which rows he's interested in and where in uploaded file he wants them to be placed.
flam:ngo save document in PDF (or DOC).
Clue
Right now I need solutions just for myself and in little simpler form. For now I need flam:ngo just to work with one specify XLSX and with one DOC template, but I stuck. I know which rows in document I will always need, but I don't know what should I write to specify in JS's code that I need exactly this ones (like hey, app, pick only this one, this one and maybe this one) while JS is reading file and I don't know how to create new DOC (or PDF) file, how to write data in specified blank spaces and then at the end: how to save it in direction which I should choose for every time I'm using an app - everything in one, maybe two, processes.
Ending
Could you, please, help me: for now I have implemented file uploader which is importing file in XLSX and which is saving it as CSV, XML oraz HTML. What should I do to keep moving forward?
I really appreciate your help!
PS. For better explanation:
For now this should look like this:
1. "template.docx" is uploaded in the core
2. user uploads .xlsx
3. app reads tables and select rows chosen in code
4. app puts data from chosen rows in specify places
5. app saves file > new life of the app :)
Ok, so it's been a while and app has been already written by me. Maybe this will help someone in the future:
Solution
Packages that helps me with this issue was:
js-xlsx which converts my file to simple HTML file, where cells from my XLSX template file have always the same ID (which was important for me to work with document templates).
officegen which helps me write brand new document based on earlier prepared template.
Rest of it was just Vanilla JS.
I have exported Netscape-Bookmark-Files as .html from Chrome, IE, and Firefox. These files are similar. Is there a way to convert this .html file into well-formed XML, for example, to view it in a TreeView in WPF? Or is there a workaround for that?
Maybe there is a better way to exchange Bookmarks under the Browsers which I don't know. Something like the JSON Files maybe....
I have to do a Project(C#) in which I have to program a little Bookmark Manager which I can Import and Export this HTML files as well as my own Bookmarks which are saved in a Database.... Do you have a better idea for this?
Please help me....
Regards
But i dont have JSON Files. I only have this f...ed up Netscape Bookmark File Format to work with. There is no Documentation for this Format. Only a poor one on Microsoft....
Treat each HTML <DT> tag like a new line.
In whatever language you have access to wrap each new line into a format that jstree.js can read so you end up with format as described here,
or simply use:
[{ id:lineCount, text:linedata},{rince and repeat}]
Then in whatever page you are using to display your tree load the json and you are good to go. Be careful you do not publish it openly as this writer would be concerned about any embeded authorization codes.
Another level of tricky would be to make each heading a parent. So in your preprocess you would create children object according to the above spec. As simple directory like re-entrant method (like you were going through a directory tree) would be able to child each group.
Then you would have
[{ id:lineCount, text:linedataParent, children[{id:lineCount, text:child, rince and repeat}, id:lineCount, text:nextParent, children:[{..and so on..}]...}]
Resulting in a somewhat nicer jsTree with parent/children the way you intended when you did your bookmark management.
Pretty sure this wont get voted best answer but it might be a start for you.
I know it seems like this question may exist elsewhere, but I haven't been able to find a solution for purely JS as a scripting language.
Is there a way for me to import a file (locally or url) like a .csv that I can then operate on?
I'm looking for a purely javascript solution, without HTML or jQuery.
for example, if there was a file called example.txt on your computer with the line "this is an example file, can you import this text?" and you had to print the 4th word in the file, how would you do that with only JS?
Or a .csv that you needed to read off you computer and return a json object of, how would you read in that CSV?
Thanks in advance for any help!
I'm work on a project recently, which need to pass a binary-stream from npapi plugin to javascript, I've tried following ways:
use NPN_InvokeDefault, i created a string variant which store the binary-stream, and invoke it to javascript, it failed. (i've tried to pass binary-stream read from XXX.txt file, it works!)
i tried to use NPN_NewStream, the example listed in http://www.terraluna.org/dgp/cvsweb/PluginSDK/Documentation/pi3.htm#npnnewstream workes, but the pic is loaded in a new browser tab, i don't know how to recieve it in javascript.
Is there any one have ever met similar problem before? or maybe npapi can't support such kind of data transfering?
looking forward to your suggestiongs, thanks a lot.
Unfortunately, NPAPI was never designed with this purpose in mind. There are a couple of ways you can do it, and none of them are really ideal:
You can create a javascript array and pass the data in small 1-4 byte chunks (this is really very inefficient)
You could create a webserver embedded in the plugin and request the data from there (I have done this and it can work quite well, but keep in mind that if you use this from an SSL website you'll get security warnings when the embedded webserver isn't SSL)
You can base64 encode the binary data and send it as a string.
Those are the ways I have seen it done. The reason you can't send the actual binary data directly as a string is that NPAPI requires string data to be UTF8, but if you base64 encode it then it works fine.
Sorry I can't give you a "happier" solution :-/