text-files

Easiest way to add a text to the beginning of another text file in Command Line (Windows)

这一生的挚爱 提交于 2019-11-29 01:03:23
What is the easiest way to add a text to the beginning of another text file in Command Line (Windows)? DarkwingDuck echo "my line" > newFile.txt type myOriginalFile.txt >> newFile.txt type newFile.txt > myOriginalFile.txt Untested. Double >> means 'append' Another variation on the theme. (echo New Line 1) >file.txt.new type file.txt >>file.txt.new move /y file.txt.new file.txt Advantages over other posted answers: minimal number of steps no temp file left over parentheses prevents unwanted trailing space in first line the move command "instantaneously" replaces the old version with the new the

Use wc on all subdirectories to count the sum of lines

左心房为你撑大大i 提交于 2019-11-29 00:20:17
问题 How can I count all lines of all files in all subdirectories with wc ? cd mydir wc -l * .. 11723 total man wc suggests wc -l --files0-from=- , but I do not know how to generate the list of all files as NUL-terminated names find . -print | wc -l --files0-from=- did not work. 回答1: You probably want this: find . -type f -print0 | wc -l --files0-from=- If you only want the total number of lines, you could use find . -type f -exec cat {} + | wc -l 回答2: Perhaps you are looking for exec option of

How to list all text (non-binary) files in a git repository?

自闭症网瘾萝莉.ら 提交于 2019-11-28 23:26:10
I have a repository with a lot of autogenerated source files I've marked as "binary" in .gitattributes (they are checked in because not everyone has access to the generator tools). Additionally, the repo has a lot of source-ish files in ignored directories (again, generated as part of the build processes), and a number of actual binary files (e.g. little resource files like icons). I'd now like to find all the non-auto-generated and non-ignored files in the repo. I thought I'd just do this with find and a bunch of exclusions, but now I have a horrendous find statement with a dozen clauses (and

Read txt file with multi-threaded in python

我与影子孤独终老i 提交于 2019-11-28 23:14:02
I'm trying to read a file in python (scan it lines and look for terms) and write the results- let say, counters for each term. I need to do that for a big amount of files (more than 3000). Is it possible to do that multi threaded? If yes, how? So, the scenario is like this: Read each file and scan its lines Write counters to same output file for all the files I've read. Second question is, does it improve the speed of read/write. Hope it is clear enough. Thanks, Ron. I agree with @aix, multiprocessing is definitely the way to go. Regardless you will be i/o bound -- you can only read so fast,

Where is hex code of the “EOF” character?

♀尐吖头ヾ 提交于 2019-11-28 21:04:59
As far as know in the end of all files, specially text files, there is a Hex code for EOF or NULL character. And when we want to write a program and read the contents of a text file, we send the read function until we receive that EOF hexcode. My question : I downloaded some tools to see a hex view of a text file. but I can't see any hex code for EOF (End Of File/NULL) or EOT (End Of Text) ASCII/Hex code tables : This is output of Hex viewer tools: Note : My input file is a text file that its content is "Where is hex code of "EOF"?" Appreciate your time and consideration. There is no such

Delphi: Alternative to using Reset/ReadLn for text file reading

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-28 20:47:20
i want to process a text file line by line. In the olden days i loaded the file into a StringList : slFile := TStringList.Create(); slFile.LoadFromFile(filename); for i := 0 to slFile.Count-1 do begin oneLine := slFile.Strings[i]; //process the line end; Problem with that is once the file gets to be a few hundred megabytes, i have to allocate a huge chunk of memory; when really i only need enough memory to hold one line at a time. (Plus, you can't really indicate progress when you the system is locked up loading the file in step 1). The i tried using the native, and recommended, file I/O

In Fortran 90, what is a good way to write an array to a text file, row-wise?

本秂侑毒 提交于 2019-11-28 20:47:00
I am new to Fortran, and I would like to be able to write a two-dimensional array to a text file, in a row-wise manner (spaces between columns, and each row on its own line). I have tried the following, and it seems to work in the following simple example: PROGRAM test3 IMPLICIT NONE INTEGER :: i, j, k, numrows, numcols INTEGER, DIMENSION(:,:), ALLOCATABLE :: a numrows=5001 numcols=762 ALLOCATE(a(numrows,numcols)) k=1 DO i=1,SIZE(a,1) DO j=1,SIZE(a,2) a(i,j)=k k=k+1 END DO END DO OPEN(UNIT=12, FILE="aoutput.txt", ACTION="write", STATUS="replace") DO i=1,numrows WRITE(12,*) (a(i,j), j=1,numcols

Reading specific columns from a text file in python

你。 提交于 2019-11-28 20:37:49
I have a text file which contains a table comprised of numbers e.g: 5 10 6 6 20 1 7 30 4 8 40 3 9 23 1 4 13 6 if for example I want the numbers contained only in the second column, how do i extract that column into a list? f=open(file,"r") lines=f.readlines() result=[] for x in lines: result.append(x.split(' ')[1]) f.close() You can do the same using a list comprehension print [x.split(' ')[1] for x in open(file).readlines()] Docs on split() string.split(s[, sep[, maxsplit]]) Return a list of the words of the string s . If the optional second argument sep is absent or None, the words are

Comparing text files with Junit

断了今生、忘了曾经 提交于 2019-11-28 17:11:24
I am comparing text files in junit using: public static void assertReaders(BufferedReader expected, BufferedReader actual) throws IOException { String line; while ((line = expected.readLine()) != null) { assertEquals(line, actual.readLine()); } assertNull("Actual had more lines then the expected.", actual.readLine()); assertNull("Expected had more lines then the actual.", expected.readLine()); } Is this a good way to compare text files? What is preferred? IAdapter junit-addons has nice support for it: FileAssert It gives you exceptions like: junitx.framework.ComparisonFailure: aa Line [3]

How to read large text file on windows? [closed]

好久不见. 提交于 2019-11-28 16:28:07
I have a large server log file (~750 MB) which I can't open with either Notepad or Notepad++ (they both say the file is too large). Can anyone suggest a program (for Windows) that will only read a small part of the file into memory at a time? Or do I need to write my own app to parse this file? Daniel Silveira try this... Large Text File Viewer By the way, it is free :) But, I think you should ask this on serverfault.com instead If all you need is a tool for reading, then this thing will open the file instantly http://www.readfileonline.com/ use EmEditor , it's pretty good, i used it to open a