F
F
fantazy5462020-08-04 11:14:31
Python
fantazy546, 2020-08-04 11:14:31

How can I find out the line number in a file and take data from it?

I have 2 files. In one and in the other data is written line by line. I need to take a specific line in one file and find data in another file by line number (maybe this can be done not by line number). Can you explain how to do it better in terms of code. Despite the fact that the files have different data and each line of one file is associated with each line of another. I need to take data from the second file, knowing in which row the data I need is in the first file.
Here are some examples of files:
first file:
14CaBzRbZDuGJCAdu9CZsbrCfyv4K7f7sf; 31
0xd4FD252d7D2C9479a8d616F510eAC6243B5DDdf9; 3
3Dxvjt7N8sbeUoTbASF5dBqEeSMc1o7Pk1; 12
0x944680402B2Ba554f978714b6039755ED10e7466; 8
second file:
0.0
0.0
7.91778246
0.5476858867775038

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
lemonlimelike, 2020-08-04
@lemonlimelike

I assume that you have the desired string. To find a line in a file, you do the following: Open the file and read this file in a loop, comparing each line with the searched line with the in operator. When comparing, translate both strings into some register lower() or upper()
And similarly with the second file

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question