76
Views
7
Comments
Download remote csv file from FTP Server, convert it to xlsx and update databases
Application Type
Reactive, Service
Service Studio Version
11.53.20 (Build 61431)

Hi there,

I want to create a Timer that executes every hour and fetches a .csv file from a remote FTP server and when the .csv is fetched I need it to be converted into .xlsx so that it can be read easily and update the data inside the database.

The issues that I face are:

 1- I have been trying to use FTPSec, SFTP and other FTP related extensions but I'm always getting an error when trying to connect to the FTP server.

2-I don't know how to use correctly the CSV to XLSX extension available in the Forge.


Any help will be much appreciated. 

Please, let me know if you need any more details.

Thanks in advance

Helder

2018-06-05 16-54-03
Maria da Graça Peixoto

what error? 

Is always the same?


UserImage.jpg
Helder Silva

Yes, its always the same error when trying to use the Server Action "Check Connection " from extension FTPSc. I never got a successful connection.

Error FTP.png
2021-03-05 13-56-11
Ricardo Pereira
 
MVP

Hi,

Did you already try to connect to the required FTP server outside Outsystems? (Filezilla or something else). 

Can you guarantee that you're not in a private network with limitations to the external network or the opposite? (the FTP server is under that circumstances).


Best regards,

Ricardo Pereira

UserImage.jpg
Helder Silva

I used WinSCP and Filezilla to connect to the FTP Server, and both connected successfully through those clients. 
when testing the FTP connection in OutSystem I subscribed to a free FTP Server called "byet.host" so that I could confirm that it wasn't just the main FTP Server that wasn't connecting properly and got the same error message.

UserImage.jpg
Helder Silva

Update
I have been using the debugging tool from outsystem to better understand where it is failing and it might be when I'm trying to download the binary data of the .csv file, since it didn't know what to do with the data it was returning "Connection Timed Out".
I added more logic to the Server Action and now it returns "Data Corrupted" which is normal since I don't know how to convert the binary data of the .csv file into .xlsx.

data corrupted.png
UserImage.jpg
Helder Silva

Here is the logic that I have implemented so far using FTPSc extension.

action_logic.png
2021-03-18 21-03-15
Benjith Sam
 
MVP

Hi Helder,

One of the options to convert the received CSV file to excel is to use an external JS library like SheetJS. You can reference the Excel Translator forge asset that has the wrapper client action called CovertCSVToXL that can be used for your requirement.

Forge asset link: Excel Translator

I hope this helps you!


Kind regards,

Benjith Sam

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.