Questions tagged [text-files]

The TXT file type is primarily associated with 'Text File'. Open in Notepad, WordPad, or many other programs designated as text editors. A true text file will be pure ASCII text with no formatting.

6722 questions
76
votes
23 answers

How to monitor a text file in realtime

For debugging purposes in a somewhat closed system, I have to output text to a file. Does anyone know of a tool that runs on windows (console based or not) that detects changes to a file and outputs them in real-time?
pbreault
  • 14,176
  • 18
  • 45
  • 38
73
votes
6 answers

How to edit a text file in my terminal

I'm using Linux mint and using the vi command to create text files, now that I created a text file and saved it. How do I get back into to edit the text file again? vi helloWorld.txt
Mad_ Questionnaire
  • 843
  • 3
  • 10
  • 11
68
votes
7 answers

Use wc on all subdirectories to count the sum of lines

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…
Jonas Stein
  • 6,826
  • 7
  • 40
  • 72
66
votes
3 answers

How to run a system command in Qt?

I have to run a system command in Qt, but I have to give an argument for that command. for example opening a text file with gedit: gedit /home/oDx/Documents/a.txt" but the path /home/oDx/Documents/a.txt will be in a variable like docPath. How can I…
defiant
  • 3,161
  • 11
  • 41
  • 65
66
votes
8 answers

Append text or data to text file in Swift

I already have read Read and write data from text file I need to append the data (a string) to the end of my text file. One obvious way to do it is to read the file from disk and append the string to the end of it and write it back, but it is not…
Ali
  • 18,665
  • 21
  • 103
  • 138
66
votes
7 answers

Clearing content of text file using php

I have a filelist.txt file and I created a file called clear.php to clear the content of filelist. I put a button in index.html to call clear.php to clear the file. Can anyone help me out regarding what PHP code I should write in clear.php? How to…
Subho Halder
  • 1,497
  • 4
  • 16
  • 30
63
votes
9 answers

How to import data from text file to mysql database

I have a 350MB file named text_file.txt containing this tab delimited data: 345868230 1646198120 1531283146 Keyword_1531283146 1.55 252910000 745345566 1646198120 1539847239 another_1531276364 2.75 987831000 ... MySQL Database name:…
Shiva Krishna Bavandla
  • 25,548
  • 75
  • 193
  • 313
62
votes
11 answers

Best way to retrieve variable values from a text file?

Referring on this question, I have a similar -but not the same- problem.. On my way, I'll have some text file, structured like: var_a: 'home' var_b: 'car' var_c: 15.5 And I need that python read the file and then create a variable named var_a with…
Strae
  • 18,807
  • 29
  • 92
  • 131
62
votes
11 answers

How do I correct the character encoding of a file?

I have an ANSI encoded text file that should not have been encoded as ANSI as there were accented characters that ANSI does not support. I would rather work with UTF-8. Can the data be decoded correctly or is it lost in transcoding? What tools could…
Liam
  • 19,819
  • 24
  • 83
  • 123
61
votes
11 answers

How to delete a line from a text file in C#?

I have a problem: how can I delete a line from a text file in C#?
alinpopescu
  • 767
  • 2
  • 6
  • 8
60
votes
2 answers

How do I limit (or truncate) text file by number of lines?

I would like to use a terminal/shell to truncate or otherwise limit a text file to a certain number of lines. I have a whole directory of text files, for each of which only the first ~50k lines are useful. How do I delete all lines over 50000?
sjmurphy
  • 686
  • 1
  • 5
  • 6
57
votes
2 answers

What is the best way to read in a text file from the server in asp.net-mvc

In one of my controller actions I need to read in a text file that has a bunch of reference data in it. Right now I simply put it in the "/Content" directory. My questions are: Is this the "right" place to put this file or should I put it in…
leora
  • 188,729
  • 360
  • 878
  • 1,366
55
votes
5 answers

difference between text file and binary file

Why should we distinguish between text file and binary files when transmitting them? Why there are some channels designed only for textual data? At the bottom level, they are all bits.
andrew
  • 885
  • 2
  • 8
  • 16
55
votes
7 answers

PHP to search within txt file and echo the whole line

Using php, I'm trying to create a script which will search within a text file and grab that entire line and echo it. I have a text file (.txt) titled "numorder.txt" and within that text file, there are several lines of data, with new lines coming in…
aullah
  • 1,334
  • 3
  • 20
  • 28
53
votes
9 answers

Comparing text files with Junit

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,…
jon077
  • 10,303
  • 11
  • 39
  • 37