Skip to content

Enhancement Proposal: Input of data using string - A Simplified Approach to Inputting Data into MESSAGEix without MS Excel #779

Discussion options

You must be logged in to vote

Thanks, @shreeyashn20! This is indeed a fluent use of pandas and Python features for data input. We do similar things in many places, for instance in message-ix-models. Here I'll give some refinements/alternate approaches to achieve the same task that your example does. To be clear, any code that achieves the intended result is fine! Different users may choose different approaches for their own reasons.

First, we can use pandas.read_fwf() which allows an input string that is perhaps even more reader-friendly:

from io import StringIO

import pandas as pd

data_var_cost = """
node_loc technology mode     time value unit
India    coal       standard year 5     $/kWh
India    gas        stand…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@khaeru
Comment options

@shreeyashn20
Comment options

Answer selected by shreeyashn20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #778 on January 12, 2024 10:51.