Split large txt file into more txtfiles - iphone

I'm having an txt file approximately 1000kb big. Now I want to use objective-c split it into 10 txt files of 100kb.
I haven't really worked with NSRange. Well I know how it works, but then to read from a given location with the length: 'to end of file'... I've no idea how to do that.
Some code on how to split this into multiple 100kb txt file would really help me out here.
Thank you in advance.

HW:
In that you tagged this question with "iphone" I would suggest that your best approach is to NOT read in the big file first and then go about segmenting it. You don't want to be a memory bully .
Other than that, this question has already been asked and answered in Here

Related

Convert abf to atf file type. Where should I start?

I want to preface this question by first saying I am not 100% sure this is the correct place to ask.
Basically, I want to take files with the .abf (axon binary files) extension and convert them to .atf (axon text files). I was wondering if I could simply just run a script that converts binary to text or if it would be more complicated than that.
I'm making a script that takes files with the .abf extension and feeds them into the Clampex9.2 program in order to save them as .atf files. However I feel like there is a much better way than manually feeding the files into a program, then resaving them with the correct extension.
Again, if this is not the right forum for this type of question, I apologize but thank you in advance if anyone can help me with this problem!

Best way to get a database friendly list of Veteran Affairs Hospital

I sincerely apologize if this isn't the proper forum to discuss this, but I wasn't sure where to go or what would be the best option.
Basically, I'm trying to find a database friendly list of veteran affairs hospitals. The closest thing that I've been able to find is www.va.gov/ofcadmin/docs/CATB.pdf as it has all the information I'm looking for:
Region
Address
City in a separate column
Zip Code in a separate column
State
Facility # (also known as StationID)
VISN
Symbol
I've tried exporting that PDF out into CSV but it's a complete nightmare to get working. So, I was curious if anyone had any ideas or insights into how I could accomplish this task.
First, here's a CSV file containing the data found in CATB.pdf. The very first line contains the column headers, and the rest of the file contains the contents.
http://tmp.alexloney.com/CATB.csv
Now, for the more detailed explanation...I took the PDF you provided a link to, converted it to an HTML document using Adobe Acrobat, then I used a lot of Regular Expressions to parse the file and clean it up. Once the file was cleaned up enough, I was able to write a program to parse through the remainder of the file, grab the state and region, and spit it all out in a nicely formatted CSV.
Hope that helps you!
I believe that PDFILL has an option in it that will convert a PDF file to Excell. Once in Excell you should have no problem converting to a CSV file.

Read from txt file in Matlab

I'm having problems reading in from a txt file in matlab. The txt file is an online review, so the delimeter I want to use is just a single whitespace. I've tried using dlmread, textscan and textread but can't seem to get it to work. I want each word in the txt file to be in a seperate cell in an array. How do I go about this?
Thanks
EDIT, this is the txt file
My husband and I satayed for two nights at the Hilton Chicago,and
enjoyed every minute of it! The bedrooms are immaculate,and the
linnens are very soft. We also appreciated the free wifi,as we could
stay in touch with friends while staying in Chicago. The bathroom was
quite spacious,and I loved the smell of the shampoo they provided-not
like most hotel shampoos. Their service was amazing,and we absolutely
loved the beautiful indoor pool. I would recommend staying here to
anyone.
textread('your_filename', '%s') should work.
If all else fails (other answers already seem good, but you specifically said the functions they proposed do not work), try something like this:
fid = fopen('test.txt');
for i = 1:1000
A{i} = fscanf(fid,'%s',1);
end
fclose(fid)
Just make sure your loop is long enough to read every word.

smlnj rephrased question for listdir(filename, directoryname)

i am a newbie learning sml and the question i am thrown with involves IO functions that i have no idea how it works even after reading it. Here is the 2 questions that i really need help with to get me started, please provide me with codings and some explaination, i will be able to trial and error with the code given for the other questions.
Q1) listdir(filename,directoryname), which given the name of a directory, list its contents in a text file. The listing is in a form that makes it easy to seperate filenames, dates and sizes from each other. (similar to what msdos does with "dir" but instead of just listing it out, it places all the files and details into a text file.
Q2) readlist(filename) which reads a list of filenames (each of which were produced by listdir in (Q1) and combines them into one large list. (reads from the text file in Q1 and then assigning the contents into 1 big list containing all the information)
Thing is, i only learned from the lecturer in school on the introduction section, there isnt even a system input or output example shown, not even the "use file" function is taught. if anyone that knows sml sees this, please help. Thanks to anyone who took the effort helping me.
Thanks for the reply, current I am using SMLNJ to try and do this. Basically, Q1 requires me to list the directory's files of the "directoryname" provided into a text file in "filename". The Q2 requires me to read from the "filename" text file and then place the contents into one large list.
Duplicate of: smlnj listdir
As a hint I will say that you have to make use of these functions:
OS.FileSys.OpenDir(directoryname) - this will open directory stream for you (Q1)
TextIO.openOut(filename) - this will open the file stream (Q2)
TextIO.openIn(filename)- this will open the file (Q2)
If you are stuck and dont' know how to do the progs then I will post the full code here, but i suggest you first give a try.
zubair sheikh

Efficient file reading techniques in C#

I am looking for the best way to read a CSV file line by line. I want to know what are the most efficient ways of doing the same. I am particulary concerned when the size of the file is big. Are the file reading utilities avilable in the .NET classes the most effient?
(PS: I have searched for the word 'Efficient' to know if someone has already posted similar question before posting this.)
You can try this: fast CSV Parser.
Here's the benchmark result:
To give more down to earth numbers,
with a 45 MB CSV file containing 145
fields and 50,000 records, the reader
was processing about 30 MB/sec. So all
in all, it took 1.5 seconds! The
machine specs were P4 3.0 GHz, 1024
MB.
The file handling in .NET is fine. If you want to read a line at a time in a comfortable way using foreach, I have a simple LineReader class you might want to look at (with a more general purpose version in MiscUtil).
With that you can use:
foreach (string line in new LineReader(file))
{
// Do the conversion or whatever
}
It's also easily usable with LINQ. You may or may not find this helpful - if the accepted solution works for you, that may be a better "off the shelf" solution.