How Do I Parse CSV/Excel Files in an OBS Bucket?
Description
How can I parse data from CSV or Excel files stored in an OBS bucket while developing applications in Huawei Cloud Astro Zero? For example, if an Excel file with a supplier list is uploaded to the OBS bucket, how do I extract and use that data in Huawei Cloud Astro Zero?

Solution
- Connect the OBS bucket to Huawei Cloud Astro Zero by referring to Interconnecting with OBS Instances.
- Use a script to obtain and parse an Excel file. That is, call the OBS connector to obtain the Excel file and call the Excel API to parse the Excel file content.
- In the navigation pane, choose Logic and click + next to Script.
- Enter a script name (for example, ScriptTest) to create a blank script.
- On the script editor, paste the following code to the code editing area.
import * as excel from 'excel'; import * as objectstorage from 'objectstorage'; let ObsCli = objectstorage.newClient(objectstorage.StoreType.OBS, "Namespace__obs", "test"); // Connector name+Bucket name let data = ObsCli.getObject("Supplier list.xlsx");//File name let x = excel.decodeAll(data); console.log(x);
Namespace__obs, test, and Supplier list.xlsx are the connector name, OBS bucket name, and Excel file name to be parsed in the bucket, respectively, which are set when you create an OBS connector in 1.
- Click
in the upper part of the page to save the script.
- After the script is saved, click
on the top of the editor page to execute the script.
- Click
in the upper right corner of the test window at the bottom of the page to return the message headers.
On the log tab page, you can view that the content has been parsed.
0814 09:25:43.931|debug|vm[1]>>> Build #AppCube Core 25.7.0 amd64 Built on 2025-08-07 19:44:28 Commit #d7cfcf8bbe 0814 09:25:43.933|debug|vm[1]>>> node: 11 0814 09:25:43.934|debug|vm[1]>>> js version: 2.0 0814 09:25:43.935|debug|vm[1]>>> log level: debug 0814 09:25:43.936|debug|vm[1]>>> script: Namespace__ScriptTest__1.0.1 0814 09:25:43.936|debug|vm[1]>>> locale: en_US 0814 09:25:43.937|debug|vm[1]>>> os timezone: Local 0814 09:25:43.938|debug|vm[1]>>> user timezone: Local 0814 09:25:43.939|debug|vm[1]>>> organization timezone: (GMT+08:00) China Standard Time (Asia/Shanghai) 0814 09:25:44.158|debug|vm[1]>>> { Supplier list: [[["Company name", "Company type", "Date of Incorporation", "Procurement Specialist", "Assessment status", "Supplier level"], ["Company A", "Foreign-funded", "1964-01-01", "Mr. He", "Assessing", "gold medal"], ["Company B", "Listed", "1968-07-18", "Mr. Guo", "Assessment completed", "gold medal"], ["Company C", "Joint-stock", "2006-08-22", "Ms. Mao", "Assessment started", "gold medal"], ["Company D", "Listed", "1984-01-01", "Mr. Li", "Assessing", "gold medal"], ["Company E", "Joint-stock", "1995-01-01", "Ms. Zhao", "Assessment completed", "gold medal"], ["Company F", "Joint-stock", "1995-03-21", "Ms. Zhao", "Assessment completed", "gold medal"], ["Company G", "Joint-stock", "1993-03-01", "Ms. Wang", "Assessment completed", "excellent"], ["Company H", "Taiwan-funded private", "1974-02-20", "Mr. Wu", "Assessment started", "gold medal"], ["Company I", "Joint-stock", "1995-04-03", "Ms. Yang", "Assessment completed", "gold medal"], ["Company G", "Listed", "1996-01-01", "Ms. Li", "Assessing", "Best"]], Import rule description and example: [["Single-choice user," "Date and time," "Date," "Multiple-choice," "Single-choice," "Phone number," "URL," "Email address," "Percentage," "Amount," "Value," "Multi-line text," "Single-line text," "Form field type"], ["a00123456", "2000-01-01 12:00:00", "2000-01-01", "Option 1, Option 2, Option 3," "Option 1", "1333**333", "https://example.com", "example@***.com", "50%", "100", "100.123456789", "Multi-line text,multi-line text,multi-line text example," "Single-line text example," "Format specification example"], ["Enter the W3 account (with letters)," "," "Use different values in this column as multiple options. Use commas (,) to separate different options.", "Use different values in this column as a single option.", "Enter the mobile phone number of the Chinese mainland.", "Enter the standard URL format.", "Enter the standard email address format.", "Enter the percentage symbol.", "", "", "", "Format description"]] } (AppTestSpace__test1:8) 0814 09:25:44.159|debug|vm[1]>>> vm memory usage -- malloc limit: 67108864, peek allocated: 284224 NAME COUNT SIZE memory allocated 1998 175264 (87.7 per block) memory used 2103 139182 (8 overhead, 17.2 average slack) atoms 862 32512 (37.7 per atom) strings 4 79 (19.8 per string) objects 350 25200 (72.0 per object) properties 1538 26912 (4.4 per object) shapes 78 18152 (232.7 per shape) bytecode functions 129 23054 bytecode 129 6321 (49.0 per function) pc2line 116 504 (4.3 per function) C functions 151 arrays 3 fast arrays 3 elements 0 0 (0.0 per fast array) binary objects 4 16564 0814 09:25:44.160|debug|vm[1]>>> sys resource usage NAME LIMIT SIZE RequestSOQLQueriesAmount 100 0 RequestSOQLRowsAmount 100000 0 RequestSOSLQueriesAmount 20 0 RequestSOSLRowsAmount 50000 0 RequestDMLStatementsAmount 150 0 RequestDMLRowsAmount 10000 0 RequestCallOutsAmount 10 0 RequestEmailSendsAmount 10 0 RequestEventSendsAmount 50 0 0814 09:25:44.161|info|vm[1]>>> release vm[1], last file: Namespace__ScriptTest, elapse time 230.752169ms, load module time 96.149µs, read file time 1.65µs load module metrics: module name read file time run code time sum load time tree child modules ----------------- ----------------- ----------------- ----------------- ----------------- excel 910ns 39.769µs 40.679µs [] objectstorage 740ns 54.73µs 55.47µs []
- After the script test is complete, click
in the upper part of the editor to activate the script.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot