I have a Model called file.rb that handles a files data table. This was done so that I can upload excel files from a file index.html.erb, and have the file name stored, see who uploaded the file, when it was created, etc(just tracking the files). These Excel files have many rows and each row have a bottle object with many attributes. During the create method, after save, I send the uploaded file to another model `bottle.rb'.
The bottle.rb model handles opening the Excel file and importing the information from the Excel file into the bottles data table.
I would like to be able to create an audit log with a message telling me success or failure of an uploaded excel file. Once the file passes the validations, I would like to see how many updates and new inserts to the bottles table. And be able to see this in the view where I upload the Excel file. I appreciate any helpful tips! I made an activity feed but for the entire application, but I am unsure how to go about to do this task.
Related
I'm investigating if it's possible for a user to: Pick a file on disk, automatically upload it to Google Sheets, do some edits, and write the changes back to the file.
I basically want to use Google Sheets as the Editor of the local file.
Has anyone tried something like this, or can confirm if it's a feasible idea?
My rough idea:
Install a script or program, that a user (on our team) can execute with the appropriate file they pick.
Typically they right-click a file and pick "Open with MyGoogleSheetsCreate".
The ToSheets-script does the following:
Generates a temporary Spreadsheet on the user's Google Drive (or possibly a Team Drive/Folder for temp files)
Reads the custom data in the local file and enters it into the Spreadsheet.
Opens a Browser window with the generated spreadsheet.
The user makes some changes to the spreadsheet.
The user exports the changes back to the file.
User initiates this how? Some ideas:
Perferably: I build a button or menu option to "Export back to Local Disk". This would only be viable if we could explicitly say where to save this custom file, i.e. where it came from.
Optionally: They right-click the original file and pick "Open with MyGoogleSheetsRetrieve". The importer would need to know the address of the Google Sheet the local file was last exported to.
FromSheets-Script converts the Spreadsheet into our custom data format and overwrites the old file.
Bonus: The temporary Google Sheet would be automatically moved to the Bin within a couple of days (without user interaction).
I think I've got a good idea of how to convert our custom format to Sheets and vice versa. The steps I'm most unsure of are: 3.1 and 5.1
I am doing file integration using mirth. There is one software which generate the HL7 files. I want to read data from that files, without moving them to another destination. Next time when I want to read data, at that time it'll ignore the files from which the data are already read (i.e.Just read the new files data which are generated after last data read).
I had done this but I'll achieve it when I modify the original filename, if I am not modifying the filename then it'll read the duplicate data.
Is there is any solution for this problem, so we can read data from the files which are generated new. I am using mirth 3.5.1 version and HL7 v2 messages.
Thanks in advance.
Thanks #daveloyall, I am posting your comment as a answer here.
When you rename a file at the time you process it, for example, to add a .DONE suffix to the filename, you are adding information that can be used later. The part of the channel that reads files could be configured to skip files that have the .DONE suffix. You also add information if you move the files. Or store the filenames in some database table. I don't know if Mirth has an internal feature that tracks which HL7 messages it already processed, but if such a feature exists, the keyword 'deduplication' might be associated with it.
I currently have a mvc task to validate the data inside the csv or excel file before it uploads to sharepoint.
I need to validate the data such as phone number format and other types of data inside the uploaded csv or excel file.if the phone number format inside the file is not correct(ex: (985)-265-abcd) the file should not validate/upload and it has thorw validation error.
Is there any way to achieve that kind of functionality
You need to create an event receiver that fires when the item is being added to the library. At that point, you need to get your file, run the validation logic, and if validation fails, cancel the event to prevent the file from uploading.
I am working on a rails engine that uploads a excel file, validates it and if there is no error than it will save it to database.
Now when ever a user mounts the engine and than go to the route provided by engine. He will have a form to upload the excel file. There are two buttons on page, i.e, upload and validate.
Once a user choose the file and when he click on upload i want that file only gets uploaded and don't get saved in db. Once i get the message the file is uploaded successfully, than i will validate the file. If it is a valid excel file with valid data than it will be saved into db. Now i am not getting how to go about it. I have seen this Railscasts video on uploading csv and excel file but here he is performing validation and save operation with import action but i want validation and save operation when user clicks on validate action. This Questions seems similar to my problem but i am not getting how do i access that uploaded file. I don't want that file to be saved in database. I mean when a user click on upload button that file gets only uploaded not saved. Than i will validate that file and save it's content to db.
This may seem very easy and simple questions for some experts but i am very new to rails and i am not sure how to go about it.
Someone please help me with a sample code, so that i can understand the workflow. Also note that both upload and validate actions are on same page. So when a file gets uploaded it needs to be stored somewhere temporarily, this is the first problem i am facing. I can do all the task if someone can tell me workflow with a sample code about uploading excel file. I am only having problem here that as both upload and validate action are on same page, so after upload request it needs to be on that page so that i can validate that file.
Any help would be appreciated, I am very beginner at rails and really confused here.
Two options:
Write code to upload the file and save to DB with a validated column set to false. Then the 'validate' button will locate the unvalidated file, validate it and set validated to true. You could have a periodic job deleting unvalidated files of a certain age. If you do this, use a helper gem like Paperclip.
Forego file upload frameworks and just manually save uploaded files to Tempfile.new 'spreadsheet'. This guide takes you through how to do that. Save that filename to session and use it to validate at a later point. When you're finally ready to persist to DB, again, consider using a helper gem.
I tried to apply the method on this page, but this sample save the files to disk instead of Database. So, could you please inform me what changes should be made on the sample method or is there any sample using this Kendo Upload to save multiple files to database?
The following method declaration -
private IEnumerable<string> GetFileInfo(IEnumerable<HttpPostedFileBase> files)
which receives the uploaded files have IEnumerable<HttpPostedFileBase> as parameter. It is collection of all the uploaded files. Each file exposes a property InputStream. For more information visit this msdn page
So now that you have the file content in form of stream, convert this stream into byte[] and save this to database.
Some suggestion are posted here.