Import CSV default coma to point-coma

Got something cool to share with AppGini users? Feel free to post it here!
Post Reply
brudy
Veteran Member
Posts: 34
Joined: 2023-02-04 11:35

Import CSV default coma to point-coma

Post by brudy » 2023-03-31 11:08

Hi,

how to change de default , to ; into import


Thanks

Rudy

jfischer
Posts: 19
Joined: 2022-11-19 16:07
Location: Austria
Contact:

Re: Import CSV default coma to point-coma

Post by jfischer » 2023-04-03 07:13

Hello Rudy

When importing, simply click in the marked field and change.

Kind regards Figo
bild-1.jpg
bild-1.jpg (23.64 KiB) Viewed 1048 times

brudy
Veteran Member
Posts: 34
Joined: 2023-02-04 11:35

Re: Import CSV default coma to point-coma

Post by brudy » 2023-04-03 14:52

Good morning,

thank you, that's what I do, but I would have liked to have the default ; and not ,

Rudy

jfischer
Posts: 19
Joined: 2022-11-19 16:07
Location: Austria
Contact:

Re: Import CSV default coma to point-coma

Post by jfischer » 2023-04-03 16:53

Hello Rudy

You can change the comma there to a semicolon. Just click and change.

Best regards
Figo

brudy
Veteran Member
Posts: 34
Joined: 2023-02-04 11:35

Re: Import CSV default coma to point-coma

Post by brudy » 2023-04-03 17:13

I understand, but I would like it to be a semicolon by default

jfischer
Posts: 19
Joined: 2022-11-19 16:07
Location: Austria
Contact:

Re: Import CSV default coma to point-coma

Post by jfischer » 2023-04-05 09:28

In AppGini you can change the delimiter from a comma to a semicolon by default when you want to upload a CSV file. Here are the steps to do it:

Go to your AppGini project and open the "hooks" directory.

Create a new PHP file named "init.php" if this file doesn't already exist.

Open the "init.php" file and paste the following code:

Code: Select all

<?php
  $config['csv_separator'] = ';'; // Ändern Sie das Trennzeichen hier auf das Semikolon
?>
Save the file and upload the changes to your server.

After following these steps, the delimiter in your AppGini project will default to a semicolon when you upload a CSV file. Please note that this change applies to all CSV files in your project. If you want to change the delimiter for a specific CSV file, you can change this in the Import Settings page.

Best regards Figo

Kommando retour! Geht nicht!

brudy
Veteran Member
Posts: 34
Joined: 2023-02-04 11:35

Re: Import CSV default coma to point-coma

Post by brudy » 2023-04-05 10:55

Hello,

Thanks for this tip but it doesn't work, I'm in version 23.10

Rudy

peebee
AppGini Super Hero
AppGini Super Hero
Posts: 348
Joined: 2013-03-21 04:37

Re: Import CSV default coma to point-coma

Post by peebee » 2023-04-06 00:49

I could be wrong but I don't think you will be able to achieve what you're after (change separator for Import CSV) using hooks.

I think you will need to edit a core generated file, which of course presents problems of it's own when regenerating an app.

The function appears to managed in \resources\lib\CSVImportUI.php

Looks like you would need to edit the default fieldSeparator in a couple of lines?

Code: Select all

if(empty($tempRequest['fieldSeparator'])) $tempRequest['fieldSeparator'] = ',';
and

Code: Select all

// force default fieldSeparator, fieldWrapper if empty
if(!$j('#fieldSeparator').text().length) $j('#fieldSeparator').html(',');
No guarantee that is going to work/not cause problems but you could try. Just keep a backup of the original file and remember that it will be overwritten if you regenerate an app.

Possibly easier and safer to just manually change the separator each time in the UI?

pböttcher
AppGini Super Hero
AppGini Super Hero
Posts: 1600
Joined: 2018-04-01 10:12

Re: Import CSV default coma to point-coma

Post by pböttcher » 2023-04-07 09:50

Hi,

looking at the code, it seems that the value is hard coded currently. So you really need to modify the core file and be aware of your changes.

As peebee mentioned, look into resources\lib\CSVImportUI.php
and search for

Code: Select all

	<div class="form-control-static" id="fieldSeparator" contenteditable>,</div>
Then replace the , with the ;
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

brudy
Veteran Member
Posts: 34
Joined: 2023-02-04 11:35

Re: Import CSV default coma to point-coma

Post by brudy » 2023-04-07 09:53

Hi,

thanks, in the meantime I've been snooping in the CSVimportUI file and I've made the change

Many thanks

Post Reply