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
1 answer

insert 4 spaces after adding multiple lines from a text file

I want to add multiple lines after matching a pattern. So from Pattern: bla to Pattern: line1-from-file1 line2-from-file1 bla I ran something like this sed '/Pattern/r file1' file2 but it…
Hud
  • 301
  • 1
  • 12
1
vote
1 answer

Writing a text file into an array on Forth

I have a text file, containing an array of numbers such as: 1 0 0 1 0 0 1 1 0 1 0 0 0 1 1 1 1 0 0 0 0 0 1 0 0 I have opened the text file with the following code: variable file-id : open_file ( -- ) \ Opens the text file s" c:\etc\textfile.txt"…
1
vote
0 answers

Open Save As Dialog to Specify Download Location

Currently I have a string that I want to save as a text file to the machine running my webpage. How do I open a Save As Dialog so the user can identify which directory the file should be saved to?
user10756438
1
vote
1 answer

How replace specific value from textfile using ofstream c++?

Hi I am working an a vending machine and I want to update the quantity of the item by updating the text file. I been trying using ofstream and ifstream but is not working. This is my text file. Water:1:1.99:D1 Coke:4:2.79:D2 Milk:6:3.15:D3 Ham…
Robby
  • 197
  • 1
  • 2
  • 14
1
vote
4 answers

PHP for read txt file line just upon sign "#"

I have this txt file structure: "data";"data";"data";#;"my data";"my data";"my data" "data";"data";"data";#;"my data";"my data";"my data" "data";"data";"data";#;"my data";"my data";"my data" I need to read this file data just after the # sign. My…
CMartins
  • 3,247
  • 5
  • 38
  • 53
1
vote
1 answer

Creating a TXT file and seeking a position in Python

I have given the following variables: signal1 = 'speed' bins1 = [0, 10, 20, 30, 40] signal2 = 'rpm' bins2 = [0, 500, 1000, 1500, 2000, 2500, 3000, 3500, 4000, 4500] hist_result = [ [1, 4, 5, 12], [-5, 8, 9, 0], …
Vikash
  • 67
  • 1
  • 7
1
vote
1 answer

(C++) Why are additional blank lines in the text file not being counted?

I have created this function to return the number of lines in a text file: int numberOfLinesInFile(string dataFile){ ifstream inputFile; inputFile.open("data.txt"); int numberOfLines, data; while(!inputFile.eof()){ …
notexactly
  • 918
  • 1
  • 5
  • 21
1
vote
1 answer

filtering data loaded from txt file to stringgrid

guys! I have this txt file and I want to load the content into a stringgrid. Here's my code : procedure PopulateStringGrid(Grid: TStringGrid; const FileName: string); var TextFile, Line: TStringList; Row, col: Integer; begin Grid.RowCount :=…
mizkyd
  • 75
  • 1
  • 11
1
vote
2 answers

Write data from one file to another line by line

I have two text files which appear as such: names.txt: andrew brian ben jerry katie katherine and nums.txt 123 456 789 012 345 678 My code currently looks like this, which adds one file to the end of the other. with open("nums.txt",) as f: …
BrianA
  • 11
  • 2
1
vote
2 answers

Why is my text file larger than my binary file?

I'm trying to write a large text file to a binary file, but the binary file is the same size as my text file. I thought that writing to a binary file would compress it? Is writing to a binary file just more efficient? How can I minimize the storage…
awildbore
  • 23
  • 2
1
vote
1 answer

Save text file with different delimiters

I have a dataframe with 100 columns, how do I export/save it using df.to_csv() with sep = ',|;' ? So after df.iloc[:, :15] with sep = ';' and df.iloc[:, 15:] with ','? I have tried to look through documentations, but I cannot find anything. Thank…
Anson
  • 57
  • 6
1
vote
1 answer

Process textfile without delimter in Spark

I have text file which is big in size(3 GB) and want to process this text file in spark. There is no delimiter in this text file. After every 50th character new record starts but there is no delimiter between the records. I'm not getting any idea on…
de-learner
  • 226
  • 1
  • 2
  • 6
1
vote
3 answers

Python - How to make every first 3 lines of text blocks into dictionary values?

I'm in an introductory Python undergraduate class and I'm working on a text file. An example of its contents can be seen below: Special Type A Sunflower 2017-10-19 18:20:30 Asteraceae Brought to the USA by Europeans Ingredient for Sunflower…
TropicalMagic
  • 104
  • 2
  • 11
1
vote
2 answers

Converting text file to dictionary with empty line as the only separator

Hi I'm trying to convert a text file into a dictionary but my separator is an empty line. So an example of part of my dummy.txt's data looks something like this: Lorem ipsum dolor sit amet (consectetur adipiscing elit) 2020-01-05 20:01:02 Lorem…
Saraht
  • 55
  • 1
  • 7
1
vote
3 answers

Is there a simple way to readlines from text file to this beautiful soup lib python script?

How can I read lines from a txt.file into this script instead of having to list urls inside the script? Thank you from bs4 import BeautifulSoup import requests url = "http://www.url1.com" response = requests.get(url) data = response.text soup =…