How do I add files to my app and find their path to access them - ios

I have some txt files that store some important data for my app. Due to its nature I want them to be in external text files. Currently i plan on reading them using a streamreader that reads the txt line by line. However, i don't know where to put my txt files, so i can access them in my streamreader which requires their path. Ive seen examples of using NSBundle.mainBundlepathforResource. However, I'm not really sure what a Bundle is or how to place my files there in the first place.

You can use NSBundle. Here's another answer that shows how to create and use bundles: https://stackoverflow.com/a/23884501/1228075

Related

I need to open some files in a folder that contains "RPA" in their name. so how can I do that in automation anywhere?

I am creating a program that opens files in a folder that contains "RPA" in their name. so, how can I do that?
You will use Loop on File in Folder command, and if condition inside the loop to check if the file name includes RPA.
Loop on Files on Folder
If condition $Filename$ includes RPA
Do Something here eg. open program/file command
End If
End Loop
#Shivam,
To get more clarity on your problem statement, you mentioned once that the files are already in PDF.
Are you trying to copy content from PDF to Word? In that case, you could use PDF Integration commands, provided the PDFs are not hand-written or scans. If that is the case, the text extraction might become more unreliable.
A safe bet with Automation Anywhere is to just extract all the text, open a new Word document and paste the content and save file.
Saving all files as word might a little counter-intuitive. You can just use the If statement within your for loop to only process files with "RPA" in their name.
Hope this help. Let us know you go :-)
its pretty simple use includes in your if statement
workbench snapshot

Identify old dos system file type and decode it into text file

I have pick up an old dos system from my friend, and I need to import the data into SQL, but before importing the data, i need to decode it into a readable text file, but I failed to do so. I have try several stuff:
file command in ubuntu terminal, it said "data"
Use online trid and it said macbin(MacBinary 1)
Tried bin2hex, but couldn't unhex it
Tried some online macbin to hex, no luck as well
Tried to open in macOS, but it keep extracting files
bin2hex said, nothing here
stuffitexpander.... Doesn't recognize...
This is the file that i need to decode
https://gofile.io/?c=wdbs6A
Please let me know if you need the original program.
I think they are just some database files.
Use this site for explanations. they even have a file analyzer - showing you the data inside.
You will need to rename the files to .db extension instead of .ocm.

Copy only new added files from one folder to another, without moving the existing files from source folder

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.

how can I open a sqlite file in ios for reading without copying to documents?

I got an app I'm working on that uses static data from a sqlite database to do various things, While I only need read only access to the database, depending on the episode they pick from the first screen I want it to use a different database file and I want the list of available episodes to be updateable on the fly. and I got help to get the list of available episodes updated, and the proper content downloaded and stored in separate folders, So I know I could when the episode is selected delete the sql file in the documents folder and copy in the new one each time and that would work well enough for what I'm trying to do. but it seems like a bit much extra work to have to check for file, delete file, copy in new one. then open it from there each time the user wants to pick a different episode. and I don't want to put all the sql files together as that will be a bigger hassle then the first route especially if this app stays around long enough to have a long list of episodes.
so my question here is: can I get at least read-only access to an sql file that I've downloaded (or one in the bundle for testing) with out having to first copy it to the documents? and if so how would i open the file?
Can I get at least read-only access to an SQL file that I've downloaded (or one in the bundle for testing) without having to first copy it to the documents directory?
Yes. Files in the app bundle are readable (if they weren't, there would be no point in storing files in the bundle).
And if so, how would I open the file?
It's not clear what you're asking here - if you want to perform SQL queries on the file, you should use the sqlite3 library which is available on iOS.

(rails) how to validate whether an uploaded .txt file is not, say, an image file?

I have a upload text file field, and with it I plan to save the file somewhere and then store the location of the file in a database. However, I want to make sure the file they uploaded is a .txt file, and not, say, an image file. I imagine this happens in the validation step. How does one validate such a thing? Also, how do you get the filename of the uploaded file? I could always just check if it said '.txt' but for future reference knowing how to validate without just the filename would be helpful.
Trying to validate the contents of a file based on the filename extension is opening the door for major hackerdom. It's trivial to change the extension and upload the file.
If you are on a Mac/Linux/Unix-based system the OS "file" command is the standard because it looks inside the file for key bytes that flag file types. http://en.wikipedia.org/wiki/File_(Unix) I'm not sure what's available for Windows, but this might help: Determine file type in Ruby
One way of doing it, the simple way really, would be to pass the file through an image loader, preferably one that handles multiple common formats, and see if it throws an error.
The other way is to manually check the file header for common image format headers. For example, .bmp files start with BM. Other formats have their own specific markings you can use.

Resources