text-files

Pandas read_csv: Data is not being read from text file (open() reads hex chars)

Pandas read_csv: Data is not being read from text file (open() reads hex chars) Question: I’m trying to read a text file with pandas.read_csv, but data is not being loaded (only a dataframe with NA values. The text file contains valid data (I can open it with excel). When I try to read it with …

Total answers: 1

Python reading text file every second line skipped

Python reading text file every second line skipped Question: I am processing a shell script in Python. My first step is to comb through the file and save only the important lines in a list (of strings). However, I have isolated a problem where every second line is ignored. Why is the second, fourth, etc. …

Total answers: 1

Split long sentences of a text file around the middle on comma (multiple commas)

Split long sentences of a text file around the middle on comma (multiple commas) Question: I have a .srt file that I’d like to split to watch with mpv. It’s a whole book turned into .srt for language learning, with an audiobook to go along. My problem is, it’s in Japanese, which doesn’t have space …

Total answers: 3

Opening textfile in python

Opening textfile in python Question: The structure of the data file looks like this: 2.0 0 3 9.15400 5.40189 0.77828 0.66432 0.44219 0.00000 2.0 0 1 9.15400 0.00000 2.0 0 6 9.15400 7.38451 3.99120 2.23459 1.49781 0.77828 0.00000 2.0 0 3 9.15400 2.09559 0.77828 0.00000 2.0 0 3 9.15400 2.09559 0.77828 0.65828 0.58990 0.00000 and …

Total answers: 1

I'm trying to find words from a text file in another text file

I'm trying to find words from a text file in another text file Question: I built a simple graphical user interface (GUI) with basketball info to make finding information about players easier. The GUI utilizes data that has been scraped from various sources using the ‘requests’ library. It works well but there is a problem; …

Total answers: 3

Read txt file with pandas into dataframe

Read txt file with pandas into dataframe Question: I want to read the txt file from here with Dota 2 mmrs for different players. It has the form as below: 1) "103757918" 2) "1" 3) "107361667" 4) "1" 5) "108464725" 6) "1" 7) "110818765" 8) "1" 9) "111436016" 10) "1" 11) "113518306" 12) "1" 13) …

Total answers: 3

Writing every two items in a list to a text file, then creating a new line

Writing every two items in a list to a text file, then creating a new line Question: Full script essentially opens a txt file with three columns separated by a whitespace and saves it to a list words with open(filename) as f: words = f.read().split() Every third item is deleted from the list starting from …

Total answers: 1

Python: Append new line of string in specific line in the hierarchical structured text file

Python: Append new line of string in specific line in the hierarchical structured text file Question: For example the content in text file is like this: Component_X Value1 Value1.1 Value1.2 #Here is where i want to append the new string# Value1.3 Value2 Value2.1 Value2.2 Value2.3 Component_Y Value1 Value1.1 Value1.2 Value1.3 Value2 Value2.1 Value2.2 Value2.3 Component_X …

Total answers: 2

Python – Combine text data from group of file by filename

Python – Combine text data from group of file by filename Question: I have below list of text files , I wanted to combine group of files like below Inv030001.txt – should have all data of files starting with Inv030001 Inv030002.txt – should have all data of files starting with Inv030002 I tried below code …

Total answers: 3

File reading only first digit of a number rather than the whole number

File reading only first digit of a number rather than the whole number Question: The problem is that i have a text file with each line being PlayerName wins with x points with each player name and number being different and obviously with them being different are different number if digits long Problem is as …

Total answers: 2