text-files

How to save string into text files in Delphi?

丶灬走出姿态 提交于 2019-12-04 10:49:49
问题 What is the easiest way to create and save string into .txt files? 回答1: Use TStringList . uses Classes, Dialogs; // Classes for TStrings, Dialogs for ShowMessage var Lines: TStrings; Line: string; FileName: string; begin FileName := 'test.txt'; Lines := TStringList.Create; try Lines.Add('First line'); Lines.Add('Second line'); Lines.SaveToFile(FileName); Lines.LoadFromFile(FileName); for Line in Lines do ShowMessage(Line); finally Lines.Free; end; end; Also SaveToFile and LoadFromFile can

print a cell array as .txt in Matlab

不打扰是莪最后的温柔 提交于 2019-12-04 10:26:28
I have a cell array that needs to be printed in a .txt file according to a specific format. I have tried some of the online help (including matlab central dlmcell but even that is not giving me the desired answer. Delimiter is \t. cellarray = { ... 'AAPL' '2/20/2011' 100.5 'MSFT' '2/15/2011' 43.4551 } ; The output should be in a .txt file with the following format: (using tab delimiter) "AAPL" "2/20/2011" 100.5 "MSFT" "2/15/2011" 43.4551 The cell will have minimum of 8000 rows and a maximum of 15000. No rows would have empty columns. Is a vectorized solution possible? Shall appreciate your

load textfile in webview android

点点圈 提交于 2019-12-04 09:58:31
so far i have read how to load "normal" html webpages in a webview .. so far I pass the URL containing the path of my text file but it loads nothing. this is my method: @Override public void onSelected(String url) { ViewerFragment viewer = (ViewerFragment) getSupportFragmentManager() .findFragmentById(R.id.view_fragment); if (viewer == null || !viewer.isInLayout()) { Intent showContent = new Intent(getApplicationContext(), ViewerFragment.class); showContent.setData(Uri.parse(url)); startActivity(showContent); } else { viewer.updateUrl(url); } } and the viewer fragment got this: public class

How can I write strings and matrices to a .txt file in MATLAB?

情到浓时终转凉″ 提交于 2019-12-04 09:26:42
问题 I need to write data to a .txt file in MATLAB. I know how to write strings ( fprintf ) or matrices ( dlmwrite ), but I need something that can do both of them. I'll give an example below: str = 'This is the matrix: ' ; mat1 = [23 46 ; 56 67] ; %fName if *fid is valid* fprintf(fid, '%s\n', str) fclose(fid) end dlmwrite(fName, *emptymatrix*, '-append', 'delimiter', '\t', 'newline','pc') dlmwrite(fName, mat1, '-append', 'newline', 'pc') This works okay, but with a problem. The first line of the

How do I get my java program to read Japanese (Unicode encoding) from a text file?

☆樱花仙子☆ 提交于 2019-12-04 06:56:32
问题 I have followed an example program from the book "Head First Java", chapter 14 page 448-459 Here's a link to the book online though Google Books: Head First Java I made sure that I had Japanese installed as a viewing language on my OS (Windows 7) and I of course have the Japanese IME in order to type in Japanese in the first place. I even saved the text file with a unicode encoding. I'm sure this has something to do with the code because it works properly with only English words. Thank you!

combining one-column text files into one multi-column file, separated by tabs

人盡茶涼 提交于 2019-12-04 06:13:05
问题 I have several one-column text files that I want to put next to each other (e.g. each file is one column). The only documentation I could find was on appending files to the bottom of other files. That's where I'm stuck. import glob MA_files = glob.glob("MA*continuous*2") with open("MA_continuous_results.csv", "wb") as outfile: for eachFile in MA_files: with open(eachFile, "rb") as infile: eachFile=eachFile.split("maskave_") # eachFile[-1] = 15_2 etc outfile.write('%s\n' % eachFile[-1]) for

Python load 2GB of text file to memory

余生颓废 提交于 2019-12-04 05:30:51
In Python 2.7, when I load all data from a text file of 2.5GB into memory for quicker processing like this: >>> f = open('dump.xml','r') >>> dump = f.read() I got the following error: Python(62813) malloc: *** mmap(size=140521659486208) failed (error code=12) *** error: can't allocate region *** set a breakpoint in malloc_error_break to debug Traceback (most recent call last): File "<stdin>", line 1, in <module> MemoryError Why did Python try to allocate 140521659486208 bytes memory for 2563749237 bytes data? How do I fix the code to make it loads all the bytes? I'm having around 3GB RAM free.

How to use “append” command on specific position in a text file using Visual Basic?

£可爱£侵袭症+ 提交于 2019-12-04 05:24:55
问题 Text file: test1 test2 test3 test4 I want to write after "test2" - something. I tried first time to open the file and I read the position where is test2. After that I opened the text file in Append format but I don't know how to write on specific position. I must to use next commands or others in Visual Basic: for reading from a text file: Open Test_Filename For Input As # for appending in a text file: Open Test_Filename For Append As #3 Any helps will be great. Edit: LineNum = 1 LineRead = 0

Reading in a text file in C, separate lines into multiple variables

夙愿已清 提交于 2019-12-04 05:09:28
问题 I'm currently working on a program that simulates various CPU scheduling methods. Currently I have the program asking for input: printf("Enter type of CPU scheduling algorithm (SJF, RR, PR_noPREMP, PR_withPREMP): "); scanf("%s", typeOf); printf("Enter number of processes: "); scanf("%d", &numPro); struct processStruct structs[numPro]; int burstTimes[numPro]; for (i = 0; i < numPro; i++) { printf("Enter process number: "); scanf("%d", &structs[i].pNum); printf("Enter arrival time: "); scanf("

How to Determine the Max and Min Values Read in From a Text File in Java

我们两清 提交于 2019-12-04 05:01:15
问题 I am doing a homework assignment for a class, and am looking for some helpful pointers, not full solutions. Basically, I have to write a Java program that reads in a text file and lists the information line by line, lists the line number, and finally, prints out the maximum and minimum value and the years that relates to each. The text file contains a year and the temperature for that year. So, it lists something like, "1900 50.9." I am not meant to use an array, or the scanner, this is part