Jump to content

Profields Table CSV Importer / Exporter


adrian

Recommended Posts

Hi @awebcreature - I have just tested with the contents of your CSV but am not seeing the problem here. Based on the line of the error, it looks like you have "Convert comma decimals to dots" checked. But none of your entries have any commas or dot decimals. Did you change the "Columns separated with" to semicolon to match your data?

Can you perhaps send me a screenshot of your settings for the import, along with the Details tab of the table field so I can see how the table fields have been defined. Also, a copy of the CSV might be good, just to make sure I am dealing with exactly the same data.

Also, can you dump $value before that error so I can see what is in the array?

Link to comment
Share on other sites

Thanks for all those details. It's really late and I need to get to sleep so I will look at this in the morning, but in the meantime, I see that you have Tracy installed, so you can just insert this line:

bd($value);

just after this line: https://github.com/adrianbj/TableCsvImportExport/blob/master/TableCsvImportExport.module#L359

This will populate the dumps panel in Tracy - please post the content here.

There must be something strange going on, because you don't have the convert decimals option checked, but it is being called anyway. Could you also add:

bd($convertDecimals);

just after this line: https://github.com/adrianbj/TableCsvImportExport/blob/master/TableCsvImportExport.module#L274

I just noticed I have an incorrect "==" which should be "===" here: https://github.com/adrianbj/TableCsvImportExport/blob/master/TableCsvImportExport.module#L339 - this shouldn't cause the problem - more of a reminder for me to change this tomorrow.

Link to comment
Share on other sites

Is there any chance this site is online and I could possibly get access to take a look?

Are all 63 errors shown in that screenshot coming from this module? Could you maybe at least show me the contents of that panel?

  • Like 1
Link to comment
Share on other sites

These errors are : 

42×PHP Notice: Array to string conversion in .../TableCsvImportExport/TableCsvImportExport.module:340

21×PHP Notice: Indirect modification of overloaded property TableRow::$Array has no effect in .../TableCsvImportExport/TableCsvImportExport.module:340

error on each element  from .csv file

Tomorrow this PW will be online.

Thanks again!

Link to comment
Share on other sites

... and i will eat my mouse!

On the my local machine i have PHP version 7. When I change it to 5.6.10 - no errors anymore. Read and import cvs file correctly into table. 

Thanks for your support Andrian! 

I hope that situation will be in plus to your future development of that useful module.

Thanks again! 

 

  • Like 1
Link to comment
Share on other sites

2 minutes ago, awebcreature said:

... and i will eat my mouse!

On the my local machine i have PHP version 7. When I change it to 5.6.10 - no errors anymore. Read and import cvs file correctly into table. 

Thanks for your support Andrian! 

I hope that situation will be in plus to your future development of that useful module.

Thanks again! 

 

Thanks for reporting that - I was struggling to figure out why you were getting those errors. I guess it's getting to the point that we all need to have a PHP7 testing environment set up so we can fix these sorts of things. 

I'll see what I can do about getting it 7 compatible fairly soon.

  • Like 1
Link to comment
Share on other sites

First of all: thank you very much for the great module.  This is so convenient to have!!!!

Just a small feedback: I managed to shoot my table down. Maybe to many entries (250) maybe and invalid file. No big deal, I have backups and the full database saved as CSV.

I got warnings from PW about not properly escaped things (don't remember exactly the wording). And, yes, I found some single and double quotes in table cells from the import file (actually an exported and then re-imported CSV file), After deleting those chars, the import worked.

If this is possible, maybe a warning about illegal chars or a proper escape during import would be very useful?

Also in my situation it would help if there was an "import & replace" feature. So I can do another import that is properly replacing a malfunctioning previous one. Right now the import was added. (Now my table has double entries - and maybe even double IDs because I cannot select and delete an entry any more, it re-appears after a save)

A replace would be a convenient way to clean this mess up quickly. 

Link to comment
Share on other sites

Hi @ceberlin - glad you are finding it convenient. Sorry there was a problem with your upload though. It shouldn't be a number of entries issue - I have imported thousands of entries without a problem (although field Table itself is slow to render with that many until Ryan adds pagination - hopefully soon).

Any chance you could send me the file in it's original form so I can test and add some checks for illegal characters etc. Just to confirm - was the exported file exported using this module? Sounds like I might have an issue there.

BTW - what version of PHP and PW are you running?

There is already an overwrite option - you just need to enable it:

Screen Shot 2016-06-18 at 3.45.19 PM.png

  • Like 1
Link to comment
Share on other sites

Hi @adrian -  thank you for your quick response.

1. Oh I see, I overlooked that feature, Brilliant!!!!!!!

(In the explanation, of you replace the word "overwrite" with "replace", it maybe gets clearer? Also i.m.h.o. it would be good to prepent the word "Caution: " maybe?)

 

2. My problem now with the import is that after the import I cannot save the page any longer (any changes/updates, regardless in what field, are ignored on save). No errors get recorded. Looks like something is timing out or confusing the database storage script.

This is the page I am working at: /tour-list/

The fields in use are a "single page" selector, a date field and some tiny text fields.

I send you PM with the data I am trying to load. And you can also have access to anything (it's a fan community website only), if you need to investigate further.

 

 

 

Link to comment
Share on other sites

SOLVED!!!!

OK, here is, what I discovered, and a workaround:

  • if you have errors on upload (database error, "not properly escaped"), look for single quotes ' in your file.
  • If you cannot change and save the page any more (you click save and the page tries to save but nothing gets actually saved any more - and no php- or js error is given) try this:
    in PHP set "max_input_vars = 5000" as a workaround.

max_input_vars = 5000 is unusual (there is a reason why the limit is normally 1000), so there is a possible bug in the pro table field which I will report now accordingly.

 

 

  • Like 1
Link to comment
Share on other sites

  • 1 month later...
On 17.6.2016 at 7:44 PM, awebcreature said:

... and i will eat my mouse!

On the my local machine i have PHP version 7. When I change it to 5.6.10 - no errors anymore. Read and import cvs file correctly into table. 

Thanks for your support Andrian! 

I hope that situation will be in plus to your future development of that useful module.

Thanks again! 

 

Hi 

I also stumbled across this problem. It looks like the new variable handling of php7 is responsible for that...

I found a solution wich works on php 5.6 and 7.

Just posted an github issue with explanation...
https://github.com/adrianbj/TableCsvImportExport/issues/1

greetings, tom

 

  • Like 3
Link to comment
Share on other sites

  • 1 month later...

Hi everyone,

I have spent quite a bit of time today getting this module working with the new pagination functionality in the Table field.

I have tested it in a variety of import (append and overwrite) and export scenarios with standard as well as page fields (radios, checkbox, selects, etc) and it seems to be working well.

The trouble is that this new version will only with with the new version of the Table field. It will work even if pagination is not enabled, but it won't work with older Table field versions.

I would really appreciate it if you guys could test and let me know how it works for you. I'd like to get this pushed to Github fairly soon, but it's such a major change that I would like some additional testing first.

Thanks!

 

PS - this update also add support for line breaks in textarea fields - I added the same CSV parser that I recently added to my BCE module.

Edited by adrian
Remove attachment because it's now on Github
  • Like 2
Link to comment
Share on other sites

Given the underwhelming response I am going to assume that not many people are using this module, so I am just going to update the Github repo with the new version. I used it a LOT yesterday and it seems to be working great with the new Table pagination feature. 

I have removed 2.7 and below from the compatibility list for this module. It is now only 3.x (or 2.8). If you need the old version that support 2.7 and below, you can grab it from this commit: https://github.com/adrianbj/TableCsvImportExport/tree/b83df4d13fd18fcb6c4bc8ac467e6ae35cba9711

Hope some of you out there will find the new version useful.

  • Like 3
Link to comment
Share on other sites

Latest version supports:

  1. Column selection and ordering for CSV export.
  2. Exported rows also respect the Find filters that have been applied.

Should be very handy for clients to be able to extract relevant info from large table datasets.

Screen Shot 2016-10-03 at 9.03.17 AM.png

  • Like 4
Link to comment
Share on other sites

  • 4 months later...

Hi!

I am getting an error on export:

Uncaught Error: Call to a member function getColumns() on null in \site\assets\cache\FileCompiler\site\modules\TableCsvImportExport\ProcessTableCsvExport.module:108

Stack trace:
#0 \site\assets\cache\FileCompiler\site\modules\TableCsvImportExport\ProcessTableCsvExport.module(62): ProcessTableCsvExport->exportCsv()
#1 \wire\core\Wire.php(374): ProcessTableCsvExport->___execute()
#2 \wire\core\WireHooks.php(698): ProcessWire\Wire->_callMethod('___execute', Array)
#3 \wire\core\Wire.php(402): ProcessWire\WireHooks->runHooks(Object(ProcessTableCsvExport), 'execute', Array)
#4 \wire\core\ProcessController.php(244): ProcessWire\Wire->__call('execute', Array)
#5 \wire\core\Wire.php(374): ProcessWire\ProcessController->___execute()
#6 \wire\core\WireHooks.php(698): ProcessW in <b>\site\assets\cache\FileCompiler\site\modules\TableCsvImportExport\ProcessTableCsvExport.module</b> on line <b>108</b><br />

testing on:

PW 3.0.52 @ php7.1
PW 3.0.48 @ php5.6.12

UPD: ProFields Table v0.1.5

Link to comment
Share on other sites

18 minutes ago, k07n said:

@adrian I have v15

Ok, I can reproduce here. I'll commit the fix shortly, but in the meantime, replace line 107 with this:

        $rows = $p->$actualFieldName(ltrim($this->wire('input')->get->filter, ',')."limit=".$totalRows);

 

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Robin S
      This module lets you add some custom menu items to the main admin menu, and you can set the dropdown links dynamically in a hook if needed.
      Sidenote: the module config uses some repeatable/sortable rows for the child link settings, similar to the ProFields Table interface. The data gets saved as JSON in a hidden textarea field. Might be interesting to other module developers?
      Custom Admin Menus
      Adds up to three custom menu items with optional dropdowns to the main admin menu.
      The menu items can link to admin pages, front-end pages, or pages on external websites.
      The links can be set to open in a new browser tab, and child links in the dropdown can be given an icon.
      Requires ProcessWire v3.0.178 or newer.
      Screenshots
      Example of menu items

      Module config for the menus

      Link list shown when parent menu item is not given a URL

      Advanced
      Setting child menu items dynamically
      If needed you can set the child menu items dynamically using a hook.
      Example:
      $wire->addHookAfter('CustomAdminMenus::getMenuChildren', function(HookEvent $event) { // The menu number is the first argument $menu_number = $event->arguments(0); if($menu_number === 1) { $colours = $event->wire()->pages->findRaw('template=colour', ['title', 'url', 'page_icon']); $children = []; foreach($colours as $colour) { // Each child item should be an array with the following keys $children[] = [ 'icon' => $colour['page_icon'], 'label' => $colour['title'], 'url' => $colour['url'], 'newtab' => false, ]; } $event->return = $children; } }); Create multiple levels of flyout menus
      It's also possible to create multiple levels of flyout submenus using a hook.

      For each level a submenu can be defined in a "children" item. Example:
      $wire->addHookAfter('CustomAdminMenus::getMenuChildren', function(HookEvent $event) { // The menu number is the first argument $menu_number = $event->arguments(0); if($menu_number === 1) { $children = [ [ 'icon' => 'adjust', 'label' => 'One', 'url' => '/one/', 'newtab' => false, ], [ 'icon' => 'anchor', 'label' => 'Two', 'url' => '/two/', 'newtab' => false, 'children' => [ [ 'icon' => 'child', 'label' => 'Red', 'url' => '/red/', 'newtab' => false, ], [ 'icon' => 'bullhorn', 'label' => 'Green', 'url' => '/green/', 'newtab' => false, 'children' => [ [ 'icon' => 'wifi', 'label' => 'Small', 'url' => '/small/', 'newtab' => true, ], [ 'icon' => 'codepen', 'label' => 'Medium', 'url' => '/medium/', 'newtab' => false, ], [ 'icon' => 'cogs', 'label' => 'Large', 'url' => '/large/', 'newtab' => false, ], ] ], [ 'icon' => 'futbol-o', 'label' => 'Blue', 'url' => '/blue/', 'newtab' => true, ], ] ], [ 'icon' => 'hand-o-left', 'label' => 'Three', 'url' => '/three/', 'newtab' => false, ], ]; $event->return = $children; } }); Showing/hiding menus according to user role
      You can determine which menu items can be seen by a role by checking the user's role in the hook.
      For example, if a user has or lacks a role you could include different child menu items in the hook return value. Or if you want to conditionally hide a custom menu altogether you can set the return value to false. Example:
      $wire->addHookAfter('CustomAdminMenus::getMenuChildren', function(HookEvent $event) { // The menu number is the first argument $menu_number = $event->arguments(0); $user = $event->wire()->user; // For custom menu number 1... if($menu_number === 1) { // ...if user does not have some particular role... if(!$user->hasRole('foo')) { // ...do not show the menu $event->return = false; } } });  
      https://github.com/Toutouwai/CustomAdminMenus
      https://processwire.com/modules/custom-admin-menus/
    • By tcnet
      This module for ProcessWire sends a notification email for each failed login attempt. Similar modules exists already in the module directory of ProcessWire. However, this module is designed to notify, even if specified user doesn't exist.
      Settings
      The settings for this module are located in the menu Modules=>Configure=>LoginFailNotifier.
      Notification email
      Specifies the email address to which the notification emails should be sent.
        Email subject
      Specifies the subject line for the notification email.
        Post variables
      Specifies the $_POST variables to be included in the notification email. Each variable must be separated by a comma. For example: login_name,login_pass
        Server variables
      Specifies the $_SERVER variables to be included in the notification email. Each variable must be separated by a comma. For example: REMOTE_ADDR,HTTP_USER_AGENT
      Link to ProcessWire module directory:
      https://processwire.com/modules/login-fail-notifier/
      Link to github.com:
      https://github.com/techcnet/LoginFailNotifier
    • By Fokke
      ProcessWire 3.x markup module for rendering meta tags in HTML document head section. Note that this module is not a full-blown SEO solution, but rather a simple tool for rendering meta tags based on module configuration. Adding custom meta tags is also supported.
      Built-in meta tags
      The following meta tags are supported out-of-the-box:
      Document title consisting of page title and site name Character set Canonical Viewport Description Keywords Hreflang tags Open Graph og:title og:site_name og:type og:url og:description og:image og:image:width og:image:height Twitter meta tags twitter:card twitter:site twitter:creator twitter:title twitter:description twitter:image Facebook meta tags fb:app_id The full documentation with configurable options can be found here: https://github.com/Fokke-/MarkupMetadata
       
      Requirements:
      ProcessWire>=3.0.0 PHP >=7.1 Installation using Composer
      composer require fokke/markup-metadata Manual installation
      Download latest version from https://github.com/Fokke-/MarkupMetadata/archive/master.zip Extract module files to site/modules/MarkupMetadata directory.
    • By m.sieber
      ITRK-Service for ProcessWire
      Module for the automated transfer of imprint, data protection declaration and terms and conditions from IT-Recht Kanzlei to your ProcessWire installation
      What is ITRK Service for ProcessWire?
      ITRK-Service for ProcessWire is a free module for ProcessWire CMS. It provides an interface to the update service of IT-Recht Kanzlei, via which the legal texts of your online presence are automatically updated. In this way, the texts remain legally secure and warning-proof in the long term. Imprint, data protection declaration, revocation and general terms and conditions are currently supported.
      You can find our documentation (in german language) here: https://www.pupit.de/itrk-service-for-processwire/dokumentation/

      Download: https://www.pupit.de/itrk-service-for-processwire/
      Github: https://github.com/pupit-de/pwItrkServiceConnector
    • By LuisM
      Symprowire is a PHP MVC Framework based and built on Symfony using ProcessWire 3.x as DBAL and Service-Provider
      It acts as a Drop-In Replacement Module to handle the Request/Response outside the ProcessWire Admin. Even tough Symfony or any other mature MVC Framework could be intimidating at first, Symprowire tries to abstract Configuration and Symfony Internals away as much as possible to give you a quick start and lift the heavy work for you.
      The main Goal is to give an easy path to follow an MVC Approach during development with ProcessWire and open up the available eco-system.
      You can find the GitHub Repo and more Information here: https://github.com/Luis85/symprowire
      Documentation
      The Symprowire Wiki https://github.com/Luis85/symprowire/wiki How to create a simple Blog with Symprowire https://github.com/Luis85/symprowire/wiki/Symprowire-Blog-Tutorial Last Update
      16.07.2021 // RC 1 v0.6.0 centralized ProcessWire access trough out the Application by wrapping to a Service https://github.com/Luis85/symprowire/releases/tag/v0.6.0-rc-1 Requirements
      PHP ^7.4 Fresh ProcessWire ^3.0.181 with a Blank Profile Composer 2 (v1 should work, not recommended) The usual Symfony Requirements Features
      Twig Dependency Injection Monolog for Symprowire Support for .env YAML Configuration Symfony Console and Console Commands Symfony Webprofiler Full ProcessWire access inside your Controller and Services Webpack Encore support Caveats
      Symfony is no small Framework and will come with a price in terms of Memory Usage and added Overhead. To give you a taste I installed Tracy Debugger alongside to compare ProcessWire profiling with the included Symfony Webprofiler

      So in a fresh install Symprowire would atleast add another 2MB of Memory usage and around 40ms in response time, should be less in production due to the added overhead of the Webprofiler in dev env
       
×
×
  • Create New...