I am not really good at python but I am trying to make a pretty basic program to concatenate tons of files, be able to filter according to some criteria, and then export a file with the result. This is what I have done so far (I still need to add a lot of input validation though):
from glob import glob
import numpy as np
import pandas as pd
pd.options.display.max_columns = 100
files = glob('C:/Personal/data*.log')
datos = pd.concat([pd.read_csv(f, header=None, names=range(100), low_memory=False) for f in files])
ip = '10.1.1.5'
user = 'john'
ini_date = '07/14/2020'
fin_date = '07/18/2020'
ini_hour = '01:42:00'
fin_hour = '16:15:20'
result = datos[(datos[0] == ip) & (datos[1] == user) & (datos[2] >= ini_date) & (datos[2] <= fin_date) & (datos[3] >= ini_hour) & (datos[3] <= fin_hour)]
result.to_csv (C:/Personal/result.csv', index = False)I would like to know the best way to do that my program ignore these variables/conditions which are not set. For example, if I run this the resut is anything:ip = '' user = 'john' ini_date = '07/14/2020' fin_date = '07/18/2020' ini_hour = '01:42:00' fin_hour = '16:15:20'I need that these null variables would be ignored or taken into account like "any". If this possible? Thanks!
