number.txt with the following content:123456789
number.txt as shown below:

3_StoreMapping.py as instructed in Preparations.3_StoreMapping.py in an editor.# custom (Change to your info)imageId = "img-m4q71qnf"Application = {"DeliveryForm": "PACKAGE","Command": "python ./codepkg/sumnum.py","PackagePath": "http://batchdemo-xxxxxxxxx.cos.ap-guangzhou.myqcloud.com/codepkg/codepkg.tgz"}StdoutRedirectPath = "your cos path"StderrRedirectPath = "your cos path"InputMapping = {"SourcePath": "cos://batchdemo-xxxxxxxxx.cos.ap-guangzhou.myqcloud.com/input/","DestinationPath": "/data/input/"}OutputMapping = {"SourcePath": "/data/output/","DestinationPath": "your output remote path"}
Configuration Item | Description |
Application | Modify `Command` to `sumnum.py`. |
InputMapping | Input mapping. `SourcePath` remote storage address: modify this address to the path of the **input** folder in "Preparations". For more information, please see Getting COS Endpoints. `DestinationPath` local directory: retain the original setting for the time being. |
OutputMapping | Output mapping. `SourcePath` local directory: retain the original setting for the moment. `DestinationPath` remote storage address: modify this address to the path of the **output** folder in "Preparations". For more information, please see Getting COS Endpoints. |
input/number.txt, add up all numbers in each row, and write the result into output/result.txt.import osinputfile = "/data/input/number.txt"outputfile = "/data/output/result.txt"def readFile(filename):total = 0fopen = open(filename, 'r')for eachLine in fopen:total += int(eachLine)fopen.close()print "total = ",totalfwrite = open(outputfile, 'w')fwrite.write(str(total))fwrite.close()print("Local input file is ",inputfile)readFile(inputfile)
python 3_StoreMapping.py
{"RequestId": "8eaeb01e-94a6-41a1-b40f-95f15417c0b4","JobId": "job-97smiptb"}
3_StoreMapping.py are stored in result.txt, which is automatically synced to COS.

result.txt is composed as below:45
Feedback