What do you want to save?
Add Code snippet
New code examples
-
Python 2021-09-12 15:09:03
parsing text in python
my_string = 'Names: Romeo, Juliet' # split the string at ':' step_0 = my_string.split(':') # get the first slice of the list step_1 = step_0[1] # split the string at ',' step_2 = step_1.split(',') # strip leading and trailing edge spaces of each item ... Add solution -
Python 2021-08-29 22:38:02
convert a text file data to dataframe in python without pandas
import csv with open('log.txt', 'r') as in_file: stripped = (line.strip() for line in in_file) lines = (line.split(",") for line in stripped if line) with open('log.csv', 'w') as out_file: writer = csv.writer(out_file) ... Add solution