Main Scripts

Titles Generation Script Documentation

8min
introduction this document outlines the process of data retrieval and processing from cybertill it details how the script is engineered to not only fetch and manipulate data but also to formulate product titles subsequently, it generates csv files which are then uploaded to ftp installation 1 clone the repository and install the dependencies git clone git\@github com\ e mps co uk/titlesscript git cd titlesscript npm install 2 run the script node index js script overview the script performs the following primary tasks retrieving data from a cybertill merging and processing the retrieved data to create product titles generating a csv file containing product details uploading the csv file to an ftp server script structure the script is organized into functions and steps here's an overview of the key functions and what they do getalldata() this function retrieves data from the database it uses a combination of limit and offset parameters to paginate through the data and collect it in chunks createfinalproducts(data) this function processes and creates final product records from the collected data it merges data by item id, extracts style attributes like color and size, and generates product names generatecsv(data) this function generates a csv file containing product details it uses the json2csv library to convert the data into csv format getdata(limit, offset) this function constructs a sql query to retrieve data from the database it incorporates filters and conditions based on configuration constants and the limit and offset values main() the main function orchestrates the entire data collection and processing workflow it performs the following steps retrieves data from the database creates product records from the collected data generates a csv file containing product details optionally, uploads the csv file to an external destination logs processing information conclusion this data collection and processing script is designed to automate the retrieval and processing of data from a database, ultimately creating product titles and generating csv files