Setting chunkcount for export actions

 I noticed that every time I save an export definition, the chunk-count definition is set to 1. However other files created earlier have their chunk-count set to 0. 

Is there a way to select the chunk-count definition when creating an export action? (small file, no need to chunk. And only files with chunkCount 0 or large files with actual chunks can be download with an API)

ex: 

export-info :
{'id': '116000000010',
'name': '116000000010',
'chunkCount': 1,
'firstDataRow': 0,
'headerRow': 0}

Thank you in advance for your help.

Answers

  • HI @cbak ,

     

    I don't think that you can change the chunk count because its auto created when an export is defined. You can refer to the below questions that has been discussed.

     

    Exporting the Files by API using Python 

    Also my understanding is when Chunk Count 0 - signifies that you are downloading the file before you trigger the export action.

    Regards,

    Riyaz Pasha

  • @cbak 

    If you're using python you can use this script here. It's best to obtain the chunk count and then iterate on it. That makes it dynamic rather than hardcoding it.

    # This script downloads a file in chunks. It will write all chunks to a newly
    # created local file with the same name as the file. 
    import requests
    import base64
    import sys
    import json
    from getAuthentication import userBA
    from getGUIDs import wGuid, mGuid, fileID, fileName

    url = (f'https://api.anaplan.com/1/3/workspaces/{wGuid}/models/{mGuid}/' +
           f'files/{fileID}/chunks')

    getHeaders = {
        'Authorization': userBA
    }

    downloadHeaders = {
        'Authorization': userBA,
        'Accept''application/octet-stream'
    }

    getChunkData = requests.get(url,
                                headers=getHeaders)
    with open('downloadChunkData.json''wb'as f:
        f.write(getChunkData.text.encode('utf-8'))

    with open('downloadChunkData.json''r'as f:
        f2 = json.load(f)

    with open(f'{fileName}''wb'as f:
        for i in f2:
            chunkData = i
            chunkID = i['id']
            print(f'Getting chunk {chunkID}')
            getChunk = requests.get(url + f'/{chunkID}',
                                    headers=downloadHeaders)
            f.write(getChunk.content)
            print('Status code: ' + str(getChunk.status_code))