-3

how can i make histogram graph by python for these values : Resistance , Noise , Leakage & Tilt in my text file , my text file have data consist of white spaces between characters with different width .

i have text file such as the following :

Box Type    Serial Nb   Sensor Type Line Name   Point Nb    Point Index Segd Code   Set Grid Easting    Set Grid Northing   Surface Elevation   Resistance(ohm) Noise (µV)  Leakage(Mo) Tilt (%)    Latest Update   
FDU-428 12263085    1   4619    1169    1   2   566443.8    3456742.2   8.0 132.23  5.78    5.0 -1.33   Sat Dec 15 12:52:17 AST 2018    
FDU-428 5848688 1   4589    1170    1   2   565641.6    3455415.0   7.4 133.2   4.99    5.0 -1.29   Sat Dec 15 12:52:17 AST 2018    
FDU-428 12318634    1   4619    1168    1   2   566401.8    3456769.2   7.5 132.3   6.26    5.0 -0.33   Sat Dec 15 12:52:17 AST 2018    
FDU-428 12280956    1   4589    1164    1   2   565390.0    3455578.5   7.4 133.46  7.85    5.0 -0.96   Sat Dec 15 12:52:17 AST 2018    
FDU-428 11271012    1   4607    1180    1   2   566551.1    3455897.5   7.1 132.8   5.81    5.0 -0.36   Sat Dec 15 12:52:17 AST 2018    
FDU-428 12245682    1   4661    1337    2   2   574607.9    3453890.8   6.7 133.32  4.14    5.0 -1.19   Sat Dec 15 12:52:17 AST 2018    
FDU-428 12307238    1   4643    1164    1   2   566860.5    3457843.0   7.3 132.42  6.71    5.0 -1.16   Sat Dec 15 12:52:17 AST 2018    
FDU-428 12319497    1   4613    1174    1   2   566462.9    3456312.5   7.4 131.86  3.92    5.0 -1.37   Sat Dec 15 12:52:17 AST 2018    
FDU-428 6046368 1   4661    1323    1   2   574018.2    3454267.8   6.8 132.94  4.82    5.0 -1.25   Sat Dec 15 12:52:17 AST 2018    

and my coding was :

myfile = open('aaa.txt','r')
myvar=(myfile.read())`
rows = (myvar.split('\n'))

for i in range(1,len(rows)):
    if float(rows[i].split('    ')[10]) > 140:
        print((rows[i].split('  ')[10])," Resitance")
    elif float(rows[i].split('  ')[11]) > 20:
        print((rows[i].split('  ')[11])," Noise")
    elif float(rows[i].split('  ')[12]) < 1: 
        print((rows[i].split('  ')[12])," Leakage")
    elif float(rows[i].split('  ')[13]) > 2.5:
        print((rows[i].split('  ')[13])," Tilt")
    elif float(rows[i].split('  ')[13]) < -2.5:
        print((rows[i].split('  ')[13])," Tilt")

how can i make histogram for over limit for these values : Resistance , Noise , Leakage & Tilt .

ywbaek
  • 2,971
  • 3
  • 9
  • 28

1 Answers1

0

I suggest you format your question for better reading.


My suggestion is: try to use pandas instead. The way for plotting histograms in pandas is:

import pandas as pd

df = pd.DataFrame({
    'column1': [1.5, 0.5, 1.2, 0.9, 3],
    'column2': [0.7, 0.2, 0.15, 0.2, 1.1]
    }
)

df[['column1','column2']].hist()
Henrique Branco
  • 1,778
  • 1
  • 13
  • 40
  • Thank you mr. Henrique , i corrected my question , please can you copy my text file and codes to be more clear , because our file have different white spaces. – Amjed Abbas Apr 13 '20 at 14:41