import PYTHON / PANDAS

Asked

Viewed 53 times

-2

I need to import a txt and take only a few characters as below:

Text:

000524WEQWE256243443507AFDAF1698100005891710232323062 

Code:

a = (0, 6) = 000524

b = (6, 5) = WEQWE

1 answer

3

Just to clarify that the title of the question:

import PYTHON / PANDAS

It means that here:

import pandas as pd

the body of the question refers to another subject...

See if it helps:

texto = "000524WEQWE256243443507AFDAF1698100005891710232323062 "

# apartir do primeiro elemento pegue seis elementos
a = texto[0:6]
print(f'a = {a}')

# apartir do sétimo elemento pegue cinco elementos
b = texto[6:11]
print(f'b = {b}')

#  do nono elemento ao último
c = texto[8:]
print(f'c = {c}')

# do primeiro ao nono elemento
d = texto[:8]
print(f'd = {d}')

Code in Repl.it: https://repl.it/repls/WingedGrownFreesoftware

Browser other questions tagged

You are not signed in. Login or sign up in order to post.