Hello. There is some kind of regular data retrieval from the csv file

f = open("file.txt", "r") r = f.read() price = re.findall(r"(\d+.\d+),.60005,", r) f.close() 

The file after uploading contains data from several warehouses. In this example, the number of the warehouse is 60005. Also in the program there is a conf-file which indicates the path, etc.

Because There is no possibility to regulate unloading by specific warehouses, the idea came to write the number of the warehouse in a conf-file to a variable, and not to change the number directly in the code. But I can not understand how (and is it possible?) To substitute data from a variable as part of the re request.

    1 answer 1

    You can do this:

     f = open("file.txt", "r") r = f.read() sklad = "60005" reg = r"(\d+.\d+),.{0},".format(sklad) REG = re.compile(reg) price = re.findall(REG, r) f.close()