Ignore:
Timestamp:
Sep 8, 2016 11:17:54 AM (6 years ago)
Author:
toby
Message:

allow comma & semicolon for .xye; validate .csv

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/imports/G2pwd_csv.py

    r2462 r2463  
    3434    # Validate the contents -- make sure we only have valid lines
    3535    def ContentsValidator(self, filepointer):
     36        good = 0
     37        for i,S in enumerate(filepointer):
     38            if i > 1000: break
     39            vals = S.replace(',',' ').replace(';',' ').split()
     40            if len(vals) >= 2:
     41                for j,v in enumerate(vals):
     42                    if j == 3: break
     43                    try:
     44                        float(v)
     45                    except ValueError:
     46                        if good > 1: return False
     47                        continue
     48                good += 1
     49                continue
     50            elif good > 1:
     51                return False
    3652        return True # no errors encountered
    3753
Note: See TracChangeset for help on using the changeset viewer.