Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import 2 different CSV in one Table #345

Open
marexx opened this issue Sep 30, 2024 · 9 comments
Open

Import 2 different CSV in one Table #345

marexx opened this issue Sep 30, 2024 · 9 comments

Comments

@marexx
Copy link

marexx commented Sep 30, 2024

HI,
I need to import 2 different CSVs in 1 Table. My setting is to import it, in 2 different Steps.

Step1:
From the FILE1 I import 2 Values
Field1 and Field2

Step2:
In FILE2 i have 2 Values
Field1 and title

No i need to import the title from File2 to the entry with the value of Field1 (is unique).

@fsuter
Copy link
Contributor

fsuter commented Oct 1, 2024

Hi. You need to have 2 configurations, one for each file and set priorities to that the second file is handled after the first one. Also, you need to disable "insert" and "delete" operations in the second configuration, because all it should do is update existing records with the title field.

@marexx
Copy link
Author

marexx commented Oct 1, 2024

yes, i thought, this is, what i did with the above config. But how do i make sure that the title is set in the correct entry?

@fsuter
Copy link
Contributor

fsuter commented Oct 1, 2024

Ah yes, I see the two configurations now. It was hard to read, because the code was not formatted. From what I see, it looks ok, but without seeing the whole configuration (i.e. including columns) and without knowing how the data is structured in each of the files, it is impossible to say what is going wrong.

@marexx
Copy link
Author

marexx commented Oct 1, 2024

<?php
defined('TYPO3') or die();
// Add the external information to the ctrl section
$GLOBALS['TCA']['tx_arzneimittelsuche_domain_model_arzneimittel']['external']['general'] = [
    0 => [
        'connector' => 'csv',
        'parameters' => [
            'filename' => 'fileadmin/user_upload/arzneimittelsuche/import_small.csv',
            //'filename' => 'fileadmin/Kundenstamm1.csv',
            'delimiter' => ";",
            'text_qualifier' => '"',
            'skip_rows' => 1,
            'encoding' => 'latin1'
        ],
        'customSteps' => [
            [
                'class' => \Securvita\Arzneimittelsuche\Step\FilterWebsiteProducts::class,
                'position' => 'after:' . \Cobweb\ExternalImport\Step\ReadDataStep::class
            ]
        ],
        'enforcePid' => true,
        'data' => 'array',
        'referenceUid' => 'pzn',
        'priority' => 10,
        //'clearCache' => 5,28,29,
        'pid' => 534,
        'group' => 'arzneimittelsuche',
        'description' => 'Importiere Medikamente'
    ],
    1 => [
        'connector' => 'csv',
        'parameters' => [
            'filename' => 'fileadmin/user_upload/arzneimittelsuche/import_name.csv',
            'delimiter' => ";",
            'text_qualifier' => '"',
            'skip_rows' => 1,
            'encoding' => 'latin1'
        ],
        'enforcePid' => true,
        'data' => 'array',
        'referenceUid' => 'atccodewho',
        'priority' => 20,
        //'clearCache' => 5,28,29,
        'pid' => 534,
        'group' => 'arzneimittelsuche',
        'disabledOperations' => 'insert,delete',

        'description' => 'Importiere Medikamentennamen'
    ]
];

$GLOBALS['TCA']['tx_arzneimittelsuche_domain_model_arzneimittel']['columns']['atccodewho']['external'] = [
    0 => [
        'field' => 'ATCCodeADV',
    ]
];

$GLOBALS['TCA']['tx_arzneimittelsuche_domain_model_arzneimittel']['columns']['pzn']['external'] = [
    0 => [
        'field' => 'PZN',
    ]
];




$GLOBALS['TCA']['tx_arzneimittelsuche_domain_model_arzneimittel']['columns']['title']['external'] = [
    1 => [
        'field' => 'Bezeichnung',
    ]
];

@marexx
Copy link
Author

marexx commented Oct 1, 2024

the import_name.csv looks like this:

`AtcCode;ParentAtcCode;Bezeichnung
A;;Alimentäres System und Stoffwechsel
A01;A;Stomatologika`

@marexx
Copy link
Author

marexx commented Oct 1, 2024

import_small.csv has more columns but as you see i import just a few. Thats already working.
i'm just missing the step to add the title

@fsuter
Copy link
Contributor

fsuter commented Oct 1, 2024

Much clearer now, thanks.

What you are missing is importing the "AtcCode" in the second configuration. The field designated in the "referenceUid" property must be imported, otherwise it is not available to be matched.

@marexx
Copy link
Author

marexx commented Oct 1, 2024

thanx, that was the solution.!!

One more Question, the complete file has about 100MB, is it possible, to loop over this file, to split the import steps?

@fsuter
Copy link
Contributor

fsuter commented Oct 1, 2024

No, this is not possible. It has been sometimes requested in the past, but it is a huge conceptual change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants