Can i give a file a unique id? - javascript

Im working with nodejs.
I have a webpage that accepts an excel upload, reads the excel and creates products based on the excels info read. My reading algorithm only works with certain format, the excel cant be written in just any random way. So i offer an excel file written in that format for the user to download, fill it (it only allows certain cells to be modified) and then upload it.
The problem is distinguishing the right file (the one i offer), from any other random file without wasting time reading it. Is there any way to give a file an id or something that certifies that it is actually the file that is suppossed to be uploaded? At first i thought about the name, but anyone can upload a random file with the same name so i dont see any way. Can you help me? Thank you

Related

Filename change with timestamp

Dynamic file generation with timestamp
Hi
I have two files like FILE_123.csv, FILE_456.csv but in real time file names will be dynamic.
So two files are coming I want to change the file name like FILE_'YYYYMMDDHH24MISS' with one second difference for each file. I think we can use wait time for each file generation by comparing each file in java script.
Can someone suggest me the code for this ?

Convert a javascript object to CSV file

I have a script which reads a file line by line, generate an object with some fields from certain lines and now I want to put that generated object into a CSV file.
How can I do the following:
From the script itself generate a CSV file
Give initial fields (headers) to the file
Update that file line by line (add to the file one line at a time)
Some clarifications, I don't know the size of the CSV in advance, so the file must by dynamically changed.
Thanks in advance.
Looking at what you have said:
From the script itself generate a csv file
Have a look at node-csv-generate which lets you generate csv strings easily
Give initial fields (headers) to the file & 3. Update that file line by line (add to the file one line at a time)
Check out the node-csv-generate stream functionality to write individually line by line (i.e. inital headers first)
Now since you said you need to run it locally, I would recommend Rhino if just using JS but if node.js is required then check out Rhinodo. These will let you run the program locally on the JVM basically (you could call the JS from within Java if you wanted to).
To export the CSV file there are plenty examples online this SO thread being one... i.e.
var encodedUri = encodeURI(csvContent);
window.open(encodedUri);
Where csvContent is the complete string of your csv. I am not sure how supported this is on Rhinodo, but I'm pretty sure it'll all work on Rhino.
If this is intended to be a purely desktop based application, I would look at using Java (or your preferred language Python or C# might be nicer depending on what you are used to :-) ) rather than JS if everything needs to be local and it intends on being widely used. That way you have a much cleaner interaction with the OS and a lot more control.
I hope this helps!

Scraping/Cleaning a HTM page into a collection using JavaScript

I have a file saved as a BLOB type in Oracle database. It's a .htm file that I want to scrape/clean and get several collections out of it.
The problem is that there are no id or class attributes. What is more there is a lot of rubbish code and in one file there are several different tables. Of each table I want to make a collection.
I thought about manually manipulating with this as a string file but the file is quite big. Could you give me some ideas on how to do so?

How to scrape javascript table in R?

I want to scrape a table from the citibike : https://s3.amazonaws.com/tripdata/index.html
My goal is to get the urls of the zip files all at once, instead of manually type all the dates and downloading one at each time. Since the webpage is updated monthly, every time I run the function, I want be able to get all the up-to-date data files.
I first tried to use Rvest and XML packages and then realized that the webpage contains both the html and a table that's generated by a javascript function. That's where the problem was.
Really appreciate any help and please let me know if I could provide further information.
If I go to https://s3.amazonaws.com/tripdata/ (just the root, no index.html) I get a simple XML file. The relevant element is Key (uppercase K, lowercase e,y) if you want to parse the XML but I would just search the plain text, that is: ignore the XML, treat it like a simple text file, get every string between <Key> and </Key> treat that as the filename that it is and prefix https://s3.amazonaws.com/tripdata/ to get it.
The first entry is all together (170 MB) as it seems, so you might be ok with that alone.

how do I download a file and then turn it into a base64 bit array?

This may seem like a silly question but here we go.
So all over the stacks I see stuff about bit arrays, but suppose I have the given link: https://files.parsetfss.com/aa780683-47b2-4d25-96f6-aff80a7daba2/tfss-6c5ff0d3-9336-4ab3-be4a-22d8371d5093-picture.jpg
The link listed above is an encrypted image file. I need to get the file from that location and then convert it into a base64 bitarray so I can then pass it to my decryptor.
Is there a good library for doing this? If so what is it, also. How do I download the file and then pass it? This may be kind of trivial, but until recently I have only done very basic javascript to display a message, not do download and manipulate its contents.

Categories

Resources