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
1
vote
0 answers

How can I use this blank space in an if statement?

I am new to programming and I am trying to scan in strings from a text file and assign each string to variables but some lines in the text file have 4 variables I need to assign but others only have 3. On the lines that only have 3 variables I need…
Jonathan
  • 11
  • 1
1
vote
2 answers

Read and write an integer to/from a .txt file

How can I read and write an integer to and from a text file, and is it possible to read or write to multiple lines, i.e., deal with multiple integers? Thanks.
user640250
  • 31
  • 2
  • 3
1
vote
0 answers

How to write to a text file in php

i am reading data from .txt file and inserting it into database in php.I want to do that whenever the code read one line the $flag variable should change to 0 for each line,and it should write it to a .txt file. my php script $open =…
1
vote
1 answer

Python sum certain values from multiple text files

I have multiple text files that contain multiple lines of floats and each line has two floats separated by white space, like this: 1.123 456.789123. My task is to sum floats after white space from each text file. This has to be done for all lines.…
Programmer
  • 306
  • 2
  • 8
1
vote
1 answer

how do i create a text file using the list that is given

I need to create a text file called Names_ages.txt using the following list Josh 14 Lauren 16 Paul 18 Mason 15 Lily 17 Stephanie 15 If anyone can help me and understand how to create one, that would be greatly appreciated :)
user12292246
1
vote
2 answers

Extract data from a text file with keywords using Python

I am working with a text data file which I have been able to extract data from as CSV/XLSX using: import pandas as pd token = open('file.txt','r') linestoken = token.readlines() resulttoken = [] for x in linestoken: …
AsiQur
  • 19
  • 4
1
vote
1 answer

parse, find chapters, and write out as separate files

I am having difficulty getting the right code to parse out chapters from this ebook and then have the 27 chapters to print out into their own text file. the farthest i've gotten is to print "CHAPTER-1.txt". I don't want to hard code anything and am…
1
vote
4 answers

Split a List into different Lists based on chunk size (Number of lines)

Lets say that i have a big list of string called "lines" and it holds all lines from a text file (Its usually big numbers around 100k - 1mil lines) List lines = File.ReadAllLines("Lines.txt"); And my problem is that i would need to split…
NAGA
  • 13
  • 3
1
vote
1 answer

Powershell read lots of text files, filter information and write into other text file as one row

For the upcoming Windows 10 Migration i need a list of MAC-addresses, IP-Addresses and computer name. Now we have lots of text files automaticly generated while users logon to the network. These text files contain the needed information. Now i want…
Roman78
  • 85
  • 3
  • 10
1
vote
0 answers

How to make 2 process in return using C# Asp.Net Core 2.2 MVC EF Core

I have a download process that after it gets the record and write it to a text file it opens a SaveFileDialog to allow users to save wherever they want. The process is working fine but after it download the file you need to refresh the page to take…
Jose Baleros Jr
  • 86
  • 1
  • 2
  • 11
1
vote
1 answer

How do I put Inputs in a notepad and open and use those values in python2.7

So, I need to use a notepad file for inputs. I can open the file and print the numbers out but can't seem to assign each line of the notepad to a variable that I can work with in the code file = open(r"C:/Users/aryaa/Desktop/Base.txt", "r") text =…
user12252269
1
vote
2 answers

In javascript, how do I use fs.writeFile and loop an array and completely print each item from the array vertically in a new text file

I am trying to use fs.writeFile to loop from an array of strings to create a new text file. I use fs.writeSync and it worked. However, when I use fs.writeFile, the content in the text file that I created does not show every item in my array.…
1
vote
1 answer

Trying to write name and age to a text file

I don't know how but it seems that my ages keep getting mixed up within the while loop. It also doesn't include one of the names. The loop works within the IDE but I can't get it to write correctly into the text file. def main(): friendsfile =…
1
vote
3 answers

My StreamReader reads only second and fourth lines from my 4 line text file

I have a program which reads data from a file and creates nodes for a graph by using that data. Problem is, from a file of 4 lines, my program creates only two nodes (one line should create one node). Text file looks like this: A/0/0.7 C/1/0/0.1…
dos
  • 13
  • 3
1
vote
4 answers

Read text file with a given structure delimitation with Python

I am trying to read a text file containing several fields structured with a given number of characters each. I know that first field takes n1 characters, second field n2 chars, ... This is what I have so far, for one line: # Line line =…
juancar
  • 187
  • 2
  • 16
1 2 3
99
100