# Pulling Well Oneline and Aggregate Monthly view via API

**URL:** <https://forum.api.combocurve.com/t/pulling-well-oneline-and-aggregate-monthly-view-via-api/284>\
**Category:** Guidance\
**Tags:** python\
**Created:** [January 22, 2024, 4:32pm UTC](https://forum.api.combocurve.com/t/pulling-well-oneline-and-aggregate-monthly-view-via-api/284 "2024-01-22T16:32:35Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![StevenDestine](https://avatars.discourse-cdn.com/v4/letter/s/aeb1de/32.png) [@StevenDestine](https://forum.api.combocurve.com/u/StevenDestine)\
**Post date:** [January 22, 2024, 4:32pm UTC](https://forum.api.combocurve.com/t/pulling-well-oneline-and-aggregate-monthly-view-via-api/284/1 "2024-01-22T16:32:35Z")

</div>

I am able to pull in one liners and monthly exports but I am not able to pull in the views from the csv export. How would I pull in data that matches the different csv export types?

 ![image](https://canada1.discourse-cdn.com/flex035/uploads/the_combocurve_api/original/1X/e5521ecdd78f4a4dbd8198176a3c710d2cec1453.png)

---

<div class="post-metadata">

**Author:** ![StevenDestine](https://avatars.discourse-cdn.com/v4/letter/s/aeb1de/32.png) [@StevenDestine](https://forum.api.combocurve.com/u/StevenDestine)\
**Post date:** [January 22, 2024, 5:33pm UTC](https://forum.api.combocurve.com/t/pulling-well-oneline-and-aggregate-monthly-view-via-api/284/2 "2024-01-22T17:33:02Z")

</div>

Here’s my code for the monthly export:

import requests  
from pyspark.sql.functions import from\_json  
from pyspark.sql.types import StructType, StructField, StringType, DoubleType, TimestampType, IntegerType, BooleanType  
import pandas as pd  
from pandas import json\_normalize  
from pyspark.sql.functions import explode

url = “[https://api.combocurve.com/v1/projects/65a6b7ea3b802055578a4804/scenarios/65a6b8983b80201e5b8abe54/econ-runs/65a7015d5a6ef903a8f208de/monthly-exports/5d944574-3da2-4dc7-a955-a042272f3f61](https://api.combocurve.com/v1/projects/65a6b7ea3b802055578a4804/scenarios/65a6b8983b80201e5b8abe54/econ-runs/65a7015d5a6ef903a8f208de/monthly-exports/5d944574-3da2-4dc7-a955-a042272f3f61)”

‘’’  
query\_params = {  
‘skip’: ‘0’,  
‘take’: 2  
}  
‘’’  
payload = {}  
headers = {  
‘Accept’: ‘application/json’,  
‘x-api-key’: x\_api\_key\_value,  
‘Authorization’: authorization\_value  
}

response = requests.get(url, headers=headers, data=payload, params=query\_params)

# Check if the request was successful (status code 200)

if response.status\_code == 200:  
# Convert JSON response to Spark DataFrame  
json\_data = pd.read\_json(response.text)

```
# Create a DataFrame from JSON data
spark_df = spark.createDataFrame(json_data)

# Show the DataFrame
df = spark_df.select(
col("results.comboName").alias("comboName"),
col("results.date").alias("date"),
col("results.output.*"),
col("status")
)

# Display the updated DataFrame
display(df)

```

else:  
print(f"Error: {response.status\_code}, {response.text}")
