FoundryProductsTechnologyCompanyInvestor relationsResource libraryNews
Contact us
Resource library
    Resource library home
    Developer resources
      Entropy quantum optimization
        Dirac Quick Start
        Dirac-3 Developer Beginner Guide
        Multibody formulation
        QUBO formulation
        QLCBO formulation
        QBoost formulation
        qci-client software package
        eqc-direct software package
        eqc-models software package
          Getting Started
          Basic Usage
          eqc_models
          Dependencies
      Quantum random number generation
      Reservoir computing
    Applications
    Lessons
    Research and publications
    Support

Couldn’t find what you are looking for? Reach out to technical support.

Contact support
Privacy PolicyCookie PolicyTerms of UseForward Looking StatementsAccessibility Statement
Terms and Conditions of SaleEnd User License Agreement

© 2018-2026 Quantum Computing Inc.

Download

Default

Source code for eqc_models.utilities.fileio

  • # (C) Quantum Computing Inc., 2024.
  • import csv
  • [docs]
  • def read_config_file(filename):
  • config = {}
  • with open(filename, 'r') as file:
  • for line in file:
  • line = line.strip()
  • if line and '=' in line:
  • key, value = line.split('=', 1)
  • config[key.strip()] = value.strip()
  • return config
  • [docs]
  • def read_coefficient_file(filename):
  • with open(filename, 'r') as file:
  • reader = csv.reader(file)
  • coefficients = [float(x) for x, in reader]
  • return coefficients
  • [docs]
  • def read_index_file(filename):
  • indices = []
  • with open(filename, 'r') as file:
  • reader = csv.reader(file)
  • for item in reader:
  • indices.append([int(x.strip()) for x in item])
  • return indices
  • def write_coefficient_file(filename, coefficients):
  • with open(filename, "w") as fp:
  • for val in coefficients:
  • fp.write(f"{val}\n")
  • def write_indices_file(filename, indices):
  • with open(filename, "w") as fp:
  • writer = csv.writer(fp)
  • for row in indices:
  • writer.writerow(row)
Next page

Content

  • Source code for eqc_models.utilities.fileio