text-files

How to deal with a very large text file?

Deadly 提交于 2019-12-03 16:23:48
问题 I'm currently writing something that needs to handle very large text files (a few GiB at least). What's needed here (and this is fixed) is: CSV-based, following RFC 4180 with the exception of embedded line breaks random read access to lines, though mostly line by line and near the end appending lines at the end (changing lines). Obviously that calls for the rest of the file to be rewritten, it's also rare, so not particularly important at the moment The size of the file forbids keeping it

Delete line from text file with line numbers from another file

北城余情 提交于 2019-12-03 16:22:16
I have a text file containing a giant list of line numbers which I have to remove from another main file. Here's what my data looks like lines.txt 1 2 4 5 22 36 400 ... and documents.txt string1 string2 string3 ... If I had a short list of line numbers I could've easily used sed -i '1d,4d,5d' documents.txt . But there are lots of lots of line number that I have to delete. Also, I could use bash/perl script to store the line numbers in an array and echo the lines which are not in the array. But I was wondering if there is a built in command to do just that. Any help would be highly appreciated.

Ghostscript convert a PDF and output in a textfile

廉价感情. 提交于 2019-12-03 15:26:51
1.I need to convert a PDF File into a txt.file. My Command seems to work, since i get the converted text on the screen, but somehow im incapable to direct the output into a textfile. public static string[] GetArgs(string inputPath, string outputPath) { return new[] { "-q", "-dNODISPLAY", "-dSAFER", "-dDELAYBIND", "-dWRITESYSTEMDICT", "-dSIMPLE", "-c", "save", "-f", "ps2ascii.ps", inputPath, "-sDEVICE=txtwrite", String.Format("-sOutputFile={0}", outputPath), "-c", "quit" }; } 2.Is there a unicode speficic .ps? Update: Posting my complete Code, maybe the error is somewhere else. public static

Mime type for .txt files?

梦想与她 提交于 2019-12-03 14:17:53
问题 I´m trying to share a .txt file with share intent. If I set "text/plain" as mime type, it reads the content like text not like text file, then the options given in the share menu are Whatsapp, Line, etc.. Does anybody know how to configure the share intent so that the share options are only the programs that are able to send a .txt file (Gmail, Dropbox, etc.. but not Whatsapp..)? Thanks 回答1: You can try the specific mime: text/plain or, the more general text mime: text/* 回答2: simple and

batch: replace a line in a text file

℡╲_俬逩灬. 提交于 2019-12-03 14:15:10
问题 I'm trying to replace this line: # forward-socks5 / 127.0.0.1:9050 . with this one: forward-socks5 / 127.0.0.1:9050 . this line belongs to a config file that has to be enabled (UN-commented) by deleting the # sign from the beginning and I could not thought of a better way other than replacing the line with another without the # sign. any other thoughts or ways would be very useful. btw, the spaces before the text are there also. I have pasted the text as it was in the original file. thanks in

Fastest/Cleanest way to load a text file in memory

﹥>﹥吖頭↗ 提交于 2019-12-03 12:38:18
I know similar questions have been asked before, but I couldn't find one that answers my exact question. I need a way to read a file as a String with the least code and as simple and as optimal as possible. I'm not looking for: final BufferedReader br = new BufferedReader(new FileReader(file)); String line = null; while ((line = br.readLine()) != null) { // logic } And I know I can write my own helper class that does this. I'm looking for something more along the lines of: final String wholeFileAsStr = Something.load(file); Where Something.load() is super optimized and buffers the file

How to print an array to a .txt file in Matlab?

会有一股神秘感。 提交于 2019-12-03 12:16:46
I am just beginning to learn Matlab , so this question might be very basic: I have a variable a=[2.3 3.422 -6.121 9 4.55] I want the values to be output to a .txt file like this: 2.3 3.422 -6.121 9 4.55 How can I do this? fid = fopen('c:\\coeffs.txt','w'); //this opens the file //now how to print 'a' to the file?? The following should do the trick: fid = fopen('c:\\coeffs.txt','wt'); % Note the 'wt' for writing in text mode fprintf(fid,'%f\n',a); % The format string is applied to each element of a fclose(fid); For more info, check out the documentation for FOPEN and FPRINTF . 来源: https:/

I Need a Human Readable, Yet Parse-able Document Format

…衆ロ難τιáo~ 提交于 2019-12-03 11:17:36
问题 I'm working on one of those projects where there are a million better ways to accomplish what I need but I have no choice and I have to do it this way. Here it is: There is a web form, when the user fills it out and hits a submit a human readable text file is created using the form data. It looks like this: field_1: value for field one field_2: value for field two more data for field two (field two has a newline in it!) field3: some more data My problem is this: I need to parse this text file

PHP library for creating/manipulating fixed-width text files

偶尔善良 提交于 2019-12-03 11:17:01
问题 We have a web application that does time-tracking, payroll, and HR. As a result, we have to write a lot of fixed-width data files for export into other systems (state tax filings, ACH files, etc). Does anyone know of a good library for this where you can define the record types/structures, and then act on them in an OOP paradigm? The idea would be a class that you hand specifications, and then work with an instance of said specification. IE: $icesa_file = new FixedWidthFile(); $icesa_file-

In Powershell, what's the most efficient way to split a large text file by record type?

大城市里の小女人 提交于 2019-12-03 10:32:17
问题 I am using Powershell for some ETL work, reading compressed text files in and splitting them out depending on the first three characters of each line. If I were just filtering the input file, I could pipe the filtered stream to Out-File and be done with it. But I need to redirect the output to more than one destination, and as far as I know this can't be done with a simple pipe. I'm already using a .NET streamreader to read the compressed input files, and I'm wondering if I need to use a