Jump to content

Profields Table CSV Importer / Exporter


adrian

Recommended Posts

@adrian: I tested 2.0.5, everything worked as expected. Another improvement, thanks!

Just for the records, I only tested importing TSV by clipboard, not to import a CSV file. All possible variants: TSV with two columns, four columns (no empty cells and rows with two empty columns), TSV with five columns--into the mentioned field with four columns.

  • Like 1
Link to comment
Share on other sites

  • 2 months later...

I had this module working OK on a site at about this time last year. Not sure what's changed since then; site was already on 3.0.48, it's now at 3.0.62, but the module itself was at version 25. When I went to use it today it added rows for each row in the CSV but the columns were either blank or 0s. So I upgraded the module to 2.0.5 and now when I save the page I get The process returned no content.

Link to comment
Share on other sites

1 hour ago, Tyssen said:

I had this module working OK on a site at about this time last year. Not sure what's changed since then; site was already on 3.0.48, it's now at 3.0.62, but the module itself was at version 25. When I went to use it today it added rows for each row in the CSV but the columns were either blank or 0s. So I upgraded the module to 2.0.5 and now when I save the page I get The process returned no content.

 

Hey @Tyssen - what version of the Profields Table are you running?

That error actually sounds more like something that might happen with the Export function than import. Can you please confirm that you are actually importing?

I just tested import and export here and everything seems to be fine, so unless it's an issue with an old version of the Table field, I will need a little more info to figure things out for you.

 

 

Link to comment
Share on other sites

I was using an older version of Profields table. I've updated to the latest and now it's creating the rows, but everything is coming out blank.

Sample row looks like

1,21-Apr,1,"Team 1","Team 2","08:30","Field 1A"

I've tried with the above and wrapping the first three columns in "" too.

Link to comment
Share on other sites

{
    "draw": {
        "id": 146,
        "type": "FieldtypeTable",
        "flags": 0,
        "name": "draw",
        "label": "Match schedule",
        "maxCols": 9,
        "col1sort": 1,
        "col2sort": 2,
        "col3sort": 3,
        "col1name": "round",
        "col1label": "Round",
        "col1type": "int2",
        "col1width": 10,
        "col2name": "date",
        "col2label": "Date",
        "col2type": "date",
        "col2width": 10,
        "col3name": "game",
        "col3label": "Game",
        "col3type": "int2",
        "col3width": 10,
        "col4name": "home",
        "col4label": "Home",
        "col4type": "text",
        "col4sort": 4,
        "col5name": "away",
        "col5label": "Away",
        "col5type": "text",
        "col5sort": 5,
        "col6name": "time",
        "col6label": "Time",
        "col6type": "datetime",
        "col6width": 15,
        "col6sort": 6,
        "col7name": "field",
        "col7label": "Field",
        "col7type": "text",
        "col7width": 10,
        "col7sort": 7,
        "col2settings": "dateInputFormat=Y-m-d\ndateOutputFormat=j M\ndatepicker=3\ndefaultToday=0\nyearRange=-10:+10",
        "col4settings": "textformatters=\nplaceholder=\ndefault=\nmaxLength=2048\nrows=1",
        "col5settings": "textformatters=\nplaceholder=\ndefault=\nmaxLength=2048\nrows=1",
        "col6settings": "dateInputFormat=\ntimeInputFormat=h:ia\ndateOutputFormat=\ntimeOutputFormat=h:ia\ndatepicker=\ndefaultToday=0\nyearRange=-10:+10\nplaceholder=",
        "col7settings": "textformatters=TextformatterEntities\nplaceholder=\ndefault=\nmaxLength=2048",
        "allow_overwrite": null,
        "col8name": "marshal",
        "col8label": "Marshal",
        "col8type": "text",
        "col8sort": 8,
        "col8settings": "textformatters=TextformatterEntities\nplaceholder=\ndefault=\nmaxLength=2048",
        "col9name": "second",
        "col9label": "Second game",
        "col9type": "text",
        "col9sort": 9,
        "col9settings": "textformatters=TextformatterEntities\nplaceholder=\ndefault=\nmaxLength=2048",
        "tags": "results",
        "collapsed": 0,
        "paginationLimit": 0,
        "useBigDelete": null,
        "col1options": "",
        "col1selector": "",
        "col2options": "",
        "col2selector": "",
        "col3options": "",
        "col3selector": "",
        "col4width": "",
        "col4options": "",
        "col4selector": "",
        "col5width": "",
        "col5options": "",
        "col5selector": "",
        "col6options": "",
        "col6selector": "",
        "col7options": "",
        "col7selector": "",
        "col8width": "",
        "col8options": "",
        "col8selector": "",
        "col9width": "",
        "col9options": "",
        "col9selector": "",
        "renameColumn": "",
        "orderByCols": "",
        "addRowLabel": "",
        "showIf": "",
        "themeColor": "",
        "themeBorder": "",
        "themeOffset": "",
        "columnWidth": 100,
        "required": "",
        "requiredIf": ""
    }
}

Not sure whether it's relevant, but my table has a column at the end that's not included in the CSV. 

Link to comment
Share on other sites

So something somewhere is not right. I'm running PW 3.0.62 with Profields Table 0.1.9 and your module 2.0.5 on a server running PHP 7.

I've looked in the logs and nothing showing up there. What else should I be looking for?

Link to comment
Share on other sites

10 hours ago, Tyssen said:

What else should I be looking for?

You could start debugging around this line: https://github.com/adrianbj/TableCsvImportExport/blob/a4e6ad668fd92f668546ba62cf726d29871b6d05/TableCsvImportExport.module#L424

Make sure that $rows contains the data.

Then continue through the rest of importCsv() to see if you can figure out where it's failing. If you don't have any luck, is this site live somewhere I can take a look?

Do you have debug mode on and Tracy installed?

  • Like 1
Link to comment
Share on other sites

Turns out the module hadn't actually been updated and was still running the old version even though I ran the update from the admin, saw that the version number had changed to 2.0.5. So not sure what happened there, but it's all good now. 👍

  • Like 1
Link to comment
Share on other sites

  • 5 months later...

hi,

the file-based csv-import (both, on a fresh import or update) quits for me in case, when i set orderByCols AND a paginationLimit >0 (onyl orderByCols set without pagination limit seems to work fine) :

Fatal error: Class 'TableRows' not found in /home/.sites/102/site1425/web/v17/site/assets/cache/FileCompiler/site/modules/TableCsvImportExport/TableCsvImportExport.module on line 386

i'm on 'version' => '2.0.5'
pw 3.0.110
table 0.1.9

the table-field has one more col than the csv-file, if that could be the problem. But works fine for everything else but the pagination thing.

thanks.

   
Link to comment
Share on other sites

Hi @martind - sorry about that. I am not sure when this started happening, but I feel like PW's file compiler is no longer correctly dealing with adding the namespace to classes in modules.

Anyway, I have implemented a fix - please check the latest version and let me know how it goes.

  • Like 1
Link to comment
Share on other sites

  • 1 month later...
1 minute ago, Robin S said:

Just popping in to say thanks for this awesome module! The "Paste in CSV Data" field saved me a heap of time today.

Glad you found it useful - thanks for the kudos!

Not sure if it's what you used, but pasting directly from Excel (using the tab delimiter) works great.

Link to comment
Share on other sites

1 minute ago, adrian said:

Not sure if it's what you used, but pasting directly from Excel (using the tab delimiter) works great.

Exactly that. It's great when you have a big messy spreadsheet and you just want to grab selections of data to add to the Table.

  • Like 1
Link to comment
Share on other sites

  • 1 year later...

Just wanted to make a note here that I just wasted several hours trying to debug why I couldn't manually add or delete rows from a table when this module was installed. Turns out it was PHP's max_input_vars setting being too low, but no error was being logged anywhere.

In the process of debugging I did fix a few bugs related to Table fields inside Repeaters and some other cleanup, so perhaps it was a worthwhile waste of time after all 🙂

  • Like 3
Link to comment
Share on other sites

  • 3 weeks later...

Hey @adrian, thanks for this great module.

Is there a way to choose a page field instead of the id when exporting a table with a page reference? I have a table with users and it would be awesome to export the name or email instead of the id. As an idea, maybe just a checkbox to export "labelField" instead of value. 

Link to comment
Share on other sites

Hi @thausmann - when exporting a table with a page reference field, it should export the title of the selected page(s), and not the ID so I am maybe confused about what you are seeing. The option to export a field from the referenced page would be great for sure. The way I'd envision this working would be for the "Columns / Order to Export" selection to work like Lister does with its ASM parents functionality where you select a parent and then get to select subfields, but I am rushed for time, so for the moment, I've just made it possible to select them as separate top-level items.

Please try the not-well-tested version attached. Please feel free to make improvements.

TableCsvImportExport.zip

  • Like 1
Link to comment
Share on other sites

Hey @adrian,

thanks a lot, I've tested your modified version. For me, subfields as top level options are totally fine, already adds a lot of possibilites for user references!

Quote

when exporting a table with a page reference field, it should export the title of the selected page(s), and not the ID

I found that my columns have type pageAutocomplete and not pageSelect, I think that's why they were exported as IDs only. I added pageAutocomplete to the fieldType checks and this works! – unless I export both "User" and "User.email", then somehow the $subfields indexes are off (Undefined offset ...). So I made one more change where the main page "User" is not added as an option anymore. To cover all cases I also added id as a subfield option. I marked my edits with //@TH SUBFIELDS

There is also pageAutocompleteMultiple, that seems to procude other problems I didn't dig into.

 

TableCsvImportExportSubfieldsTH.zip

  • Like 1
Link to comment
Share on other sites

Thanks @thausmann for those fixes and improvements - I've made a couple of small tweaks:

1) the title subfield is automatically selected now so that users don't need to do anything when exporting to get each column automatically added.

2) I added support for pageAutocompleteMultiple

New version is committed to the repo and updated in the modules directory.

  • Like 2
Link to comment
Share on other sites

  • 2 weeks later...

I keep getting an error for an frontend page to import csv.

image.thumb.png.cd30d8aeab1c32a8380327e54a76de9b.png

$wire->modules->get('TableCsvImportExport'); // load module
$options = array(
    'delimiter' => ',',
    'enclosure' => '"',
    'convertDecimals' => false,
    'multipleValuesSeparator' => '|',
    'namesFirstRow' => false
);
$page->importTableCsv('importTableCsv'$csvData$options);

For testing page table field is also called importTableCsv

  • Like 1
Link to comment
Share on other sites

Hi @webhoes - firstly, sorry for the late response, I was on vacation last week.

I have fixed the issue you were seeing. Not sure when that showed up - seems like maybe a change to the PW may have caused it. Anyway, should be fine now, but please let me know how it goes for you.

PS - is your table field really named "importTableCsv" ? You probably want to change the first parameter in that call to the $page->importTableCsv() method to the fieldname.

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...