how to have next line exporting csv file in iphone - iphone

How to give next line in row value if I have multiple value in one row and show in exporting csv file .
I want add text as new line this code is doing well, but I have multiple value in one row then it does not print that row, it only prints another row. How to solve this problem
buffer is string.
buffer = [buffer stringByAppendingFormat: #"\r\n%#", rowString];

"\n\n" should give you a new line.

Related

no carriage return while using dlmwrite( ) to write array values to file in Matlab

I am trying to write the array values to CSV file in MATLAB using the following code
m=[3 12 15 ; 4 23 565];
dlmwrite('C:\Users\amar-admin\Desktop\abc.txt', m)
type C:\Users\amar-admin\Desktop\abc.txt
the output printed in the console is
3,12,15
4,23,565
but the output in File is
3,12,154,23,565
You may want to set the 'newline' option to 'pc':
dlmwrite('C:\Users\amar-admin\Desktop\abc.txt', m, 'newline', 'pc');
This will ensure that the file is created with a carriage return (\r) and a line feed (\n) at the end of each line, instead of potentially just a line feed, which could affect how it is displayed in certain text viewers. See this post for more information about the differences between \n and \r.
the issue was solved using .rtf extension
dlmwrite('C:\Users\amar-admin\Desktop\abc.rtf', m)
But, I still wonder if same is possible to .txt file

Detecting selected text with powershell

Is it possible to detect selected text with powershell?
For instance, say I opened a text file that contained an essay and then sent a command to select the first line.
Is there a way to return the first line of that file as a string?
If you are trying to iterate over the lines of a text file you can access them like this:
$file = Get-Content essay.txt
$file[0] # for first line
$file[$file.Length - 1] # for last line

How to replace last line of the file with a new text?

I am appending a file in scala, and I want to replace the last line of the file with a new text. I know how to append to a file, but I can't figure out how to overwrite the last line.
I am appending like this:
val fw = new FileWriter("src/file.txt", true) ;
fw.write("new item");
Could anybody help?
The most efficient way I can think of is the following:
Read the file as a RandomAccessFile.
Go to the end of the file Start reading backwards till you find the
end of the last but one line.
Get rid of this last line
Append your line to this new file
Here is an example of how to remove the last line in Java using RandomAccessFile.
Delete last line in text file

How to get the number of columns of a csv file?

I have a huge csv file that I want to load with matlab. However, I'm only interested in specific columns that I know the name.
As a first step, I would like to just check how many columns the csv file has. How can I do that with matlab?
As Jonesy and erelender suggest, I would think this will do it:
fid=fopen(filename);
tline = fgetl(fid);
fclose(fid);
length(find(tline==','))+1
Since you don't seem to know what kind of carriage return character (or character encoding?) is being used then I would suggest progressively sampling your file until you encounter a recognizable CR character. One way to do this is to loop over something like
A = fscanf(fileID, ['%' num2str(N) 'c'], sizeA);
where N is the number of characters to read. At each iteration test A for presence of carriage return characters, stop if one is encountered. Once you know where the carriage return is just repeat with the right N and perform the length(find...) operation, or alternately accumulate the number of commas at each iteration. You may want to check that your file is being read along rows (is it always?), check a few samples to make sure it is.
1-) Read the first line of file
2-) Count the number of commas, or seperator characters if it is not comma
3-) Add 1 to the count and the result is the number of columns in the file.
If the csv has only numeric value you can use:
M=csvread('file_name.csv');
[row,col]=size(M);

What is 0xdb8844?

I am reading a text file into an NSArray as below:
Hi.This is the first line.
--blank line--
Hey, this is the second line.
--blank line--
...
This NSArray reads every line including a blank line just like the above, but I find
this 0xdb8844 in the second element of the NSArray. I think it represents a blank line
in hexadecimal or UTF-8. Can any one tell me how to decode this?
Thank you for your time.
That is the memory address of the element stored in the array.
If you want to see what is stored there, add the following line after you read in the text file:
NSLog(#"Array element 1: '%#'.", [array objectAtIndex:1]);
It probably is the blank line, based on what you have here, and will print the following log statement which indicates that it is indeed the blank line:
Array element 1: ''.