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
3 answers

How to find a word from text file by position index in python?

I have a text file that I want to extract different words from, using a position index given by the user. for example, the text is: i believe i can fly i believe i can touch the sky i think about it every night and day spread my wings and fly away I…
dvd
  • 23
  • 1
  • 3
1
vote
2 answers

Populating a DataTable with a Text File

I am making a password manager for myself and am storing all of the data locally within a text file. I am not worried about security at the moment, simply trying to get it to work. I can read from the text file fine and have each of my entries split…
Ethan
  • 35
  • 9
1
vote
2 answers

Is there a way to make my python text files unopenable/unreadable

I would like to store some information for a game I'm making in python using text files. Some of the information stored shouldn't be changeable for the user. Is there any easy way to make the files unopenable/unreadable for a user, however it would…
1
vote
2 answers

How to skip N central lines when reading file?

I have an input file.txt like this: 3 2 A 4 7 B 1 9 5 2 0 I'm trying to read the file and when A is found, print the line that is 2 lines below when B is found, print the line that is 4 lines below My current code and current output are…
Ger Cas
  • 2,188
  • 2
  • 18
  • 45
1
vote
0 answers

How do I print a tibble to a text file with nice formatting?

Tibbles in the tidyverse makes it pleasing to view data tables. How do I print the nicely formatted text to a text file (or rich text file) for viewing, so that I don't have to open the IDE to view the formatted data strings? For…
HackJob99
  • 89
  • 5
1
vote
1 answer

Python doesn't write every line to output file

I am trying to format/clean some data from a text file using Python. The columns are separated by tabs, and I only want certain columns from each row. I am running into a problem that is not making any sense to me and would appreciate some help. I…
woot
  • 21
  • 1
1
vote
1 answer

Python discord.py ways to split output to bypass 2000 character limit

I am attempting to output the contents of a text file to a discord channel via Discord. The issue I have is that there is a 2000 character limit. I have been able to bypass this by using the code below async def on_message(message): id =…
Brendan Rodgers
  • 305
  • 2
  • 17
1
vote
1 answer

Python - Contents of text file being posted as separate messages rather than one message using Discord.py bot

I am currently attempting to post the contents of a text file to a discord channel using Discord.py The text file contents are below: Competition English Premier League - Week 35 Competitors Wolves v Everton Match Date Sunday, 12th July Match…
Brendan Rodgers
  • 305
  • 2
  • 17
1
vote
2 answers

Why isn't this Python code copying the text in one file to another?

So,I am attempting to copy some text from one .txt file to another. However,when I open the second .txt file,the lines have not been written there by the program. This is the code that I'm using. chptfile =…
Kingsod
  • 115
  • 8
1
vote
1 answer

Replace path in text file using Powershell

I want to remove the path G:\Data\editor\ from a text file and replace it with ..\ using powershell. How do I go about doing that? powershell -Command "(gc sample.txt) -replace 'G:\Data\editor\', '..\' | Out-File -encoding ASCII sample.txt" I had…
JamesRocky
  • 721
  • 9
  • 23
1
vote
1 answer

How to append desired different length sublist elements?

I have a text like below that I want to store in a dictionary, storing values of the same parameters (keys) in sublists. file = """./path/to/Inventory2020_1.txt fileType = Inventory StoreCode number:1145C numId …
Ger Cas
  • 2,188
  • 2
  • 18
  • 45
1
vote
1 answer

Angular how to create a downloadable text file?

I am creating a project that takes a GET call from an API and writes out select data from the result to a text file. I understand how to call the API and to print out the select data to the console and the page itself, but I am struggling with…
Petlover620
  • 115
  • 1
  • 11
1
vote
5 answers

Extract substrings from a text file on each line?

Is there a way to extract substrings from a textfile from each like e.g. Say this is the text file but with alot more lines like this: president, Donald Trump, 74, USA Priminster, Boris Johnson, 56, UK I would need to loop through each line and get…
user7491773
1
vote
3 answers

Filling each slot of an array with a line (String) from a text file

I have a text file list of thousands of String (3272) and I want to put them each into a slot of an Array so that I can use them to be sorted out. I have the sorting part done I just need help putting each line of word into an array. This is what I…
1
vote
5 answers

Problem with Java FileReader

Hello I have this in my code File file = new File("words.txt"); Scanner scanFile = new Scanner(new FileReader(file)); ArrayList words = new ArrayList(); String theWord; while (scanFile.hasNext()){ theWord…
randomizertech
  • 2,309
  • 15
  • 48
  • 85