Logging in Python console and in log file

Issue I’m using the logging library and would like to log on to the console and store those logs in a file. logger = logging.getLogger(module) handler = logging.StreamHandler() formatter = logging.Formatter( ‘%(asctime)s [%(name)s] %(levelname)-8s %(message)s’) handler.setFormatter(formatter) logger.addHandler(handler) logger.setLevel(logging.DEBUG) filehandler=logging.FileHandler(‘logfile.log’) logger.addHandler(filehandler)

Continue reading

Convert columns in (.csv) file to (.json) column array in Python

Issue I am trying to convert a (.csv) file to a .json file which is stored in the form of a column array. The input (.csv) file is: This is my desired result: { "wavelength":[0.033962528,0.035974933,0.03801894,0.039994474,0.041975898,0.043954162], "n":[0.842171,0.83072,0.819753,0.809997,0.802291,0.797737], "k":[0.090738197,0.10934279,0.13025372,0.15338756,0.17980019,0.20882868], "alpha":[33573761.42,38194428.97,43052660.58,48194781.27,53826980.05,59703529.05], "absorption_length":[2.98e-8,2.62e-8,2.32e-8,2.07e-8,1.86e-8,1.67e-8] }

Continue reading

Django TemplateDoesNotExist?

Issue My local machine is running Python 2.5 and Nginx on Ubuntu 8.10, with Django builded from latest development trunk. For every URL I request, it throws: TemplateDoesNotExist at /appname/path appname/template_name.html Django tried loading these templates, in this order: *

Continue reading

what the bars in keras training show?

Issue I am using keras and part of my network and parameters are as follows: parser.add_argument(“–batch_size”, default=396, type=int, help=”batch size”) parser.add_argument(“–n_epochs”, default=10, type=int, help=”number of epoch”) parser.add_argument(“–epoch_steps”, default=10, type=int, help=”number of epoch step”) parser.add_argument(“–val_steps”, default=4, type=int, help=”number of valdation step”)

Continue reading

Align columns in a text file

Issue I have a plain text file that contains user login data: dtrapani HCPD-EPD-3687 Mon 05/13/2013 9:47:01.72 dlibby HCPD-COS-4611 Mon 05/13/2013 9:49:34.55 lmurdoch HCPD-SDDEB-3736 Mon 05/13/2013 9:50:38.48 lpatrick HCPD-WIN7-015 Mon 05/13/2013 9:57:44.57 mlay HCPD-WAR-3744 Mon 05/13/2013 10:00:07.94 eyoung HCPD-NLCC-0645 Mon

Continue reading

Overriding in Python

Issue I want to be able to do the following class Parent: def __init__(self): pass def Create(self): return ‘Password’ class Child(Parent): def __init__(self): self.Create() def Create(self): return ‘The ‘+self.Create #I want to return ‘The Password’ I would like to get

Continue reading

Python 3: Variable Scoping

Issue def max_sum_subarray(arr): cur_max_sum = global_max_sum = arr[0] start = end = 0 sz = len(arr) for i in range(1, sz): cur_max_sum = max(arr[i], cur_max_sum+arr[i]) global_max_sum = max(global_max_sum, cur_max_sum) if cur_max_sum > global_max_sum: global_max_sum = cur_max_sum end = i g

Continue reading

ImportError: cannot import name 'device_spec' from 'tensorflow.python.framework'

Issue When i try to run python train.py –logtostderr –train_dir=training/ –pipeline_config_path=training/faster_rcnn_inception_v2_pets.config command this error pops out. (tensorflow1.13) C:\tensorflow1\models\research\object_detection>python train.py –logtostderr –train_dir=training/ –pipeline_config_path=training/faster_rcnn_inception_v2_pets.config Traceback (most recent call last): File "train.py", line 51, in from object_detection.builders import dataset_builder File "C:\tensorflow1\models\research\object_detection\builders\dataset_builder.py", line 33,

Continue reading

Split image dataset into train-test datasets

Issue So I have a main folder which contains sub-folders which in turn contains images for the dataset as follows. -main_db —CLASS_1 —–img_1 —–img_2 —–img_3 —–img_4 —CLASS_2 —–img_1 —–img_2 —–img_3 —–img_4 —CLASS_3 —–img_1 —–img_2 —–img_3 —–img_4 I need to split

Continue reading