Changeset 514a00e in sasview for src/sas/sasgui/perspectives


Ignore:
Timestamp:
Aug 9, 2016 10:30:33 AM (8 years ago)
Author:
lewis
Branches:
master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
35488b2
Parents:
d889d80
Message:

Check for BSL header if loading ASCII file fails

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sas/sasgui/perspectives/file_converter/converter_panel.py

    rf5c52b0 r514a00e  
    153153        :return: A numpy array containing the extracted data 
    154154        """ 
    155         data = np.loadtxt(filename, dtype=str) 
     155        try: 
     156            data = np.loadtxt(filename, dtype=str) 
     157        except: 
     158            is_bsl = False 
     159            # Check if file is a BSL or OTOKO header file 
     160            f = open(filename, 'r') 
     161            f.readline() 
     162            f.readline() 
     163            bsl_metadata = f.readline().strip().split() 
     164            f.close() 
     165            if len(bsl_metadata) == 10: 
     166                msg = ("Error parsing ASII data. {} looks like a BSL or OTOKO " 
     167                    "header file.") 
     168                raise Exception(msg.format(os.path.split(filename)[-1])) 
    156169 
    157170        if len(data.shape) != 1: 
Note: See TracChangeset for help on using the changeset viewer.