Important announcements from CouchCMS team
55 posts Page 6 of 6
Previous 1, 2, 3, 4, 5, 6 Next
That worked perfectly. Thanks for the help.
I'm dealing with a situation in which the CSV file is an export from an Excel sheet, used to keep track of an organisations small library of books. The potential problem is that the Excel sheet is also used directly, and it has some column headers with spaces in them (for example, 'Number of Copies').

The problem is that the CSV importer tries to write these into Couch variables with a space in the name, and trying to use variables with an embedded space doesn't go well!

To deal with this, I've added a line to the CSV importer as below (the line is commented; the others are for context). This simply replaces the spaces with underscores; if your data source uses underscores *and* spaces this may get confusing, but I guess that's fairly uncommon!

Code: Select all
                    foreach( $rec as $k=>$v ){
                        $k = str_replace(" ","_",$k); //replace spaces with underscores in column headers
                        $CTX->set( $prefix.$k, $v );
                    } 


This is at lines 356-358 of the file in the download linked on the first post of this topic, but looking at the Github repo it's at lines 363-366 in the latest version. I probably need to upgrade!

@KK - feel free to incorporate / criticise!
@daldred, there was a recent discussion on this very topic -
viewtopic.php?f=4&t=13080&p=37361#p37361

As you'll find in the solution suggested by me there, spaces in variable names can be handled without much difficulty and so, IMHO, there should be no need to modify the addon's code.

Would like to get your thoughts.
KK wrote: @daldred, there was a recent discussion on this very topic -
viewtopic.php?f=4&t=13080&p=37361#p37361

As you'll find in the solution suggested by me there, spaces in variable names can be handled without much difficulty and so, IMHO, there should be no need to modify the addon's code.

Would like to get your thoughts.


I don't know how I managed to miss that one when looking in the forums...

I think there are advantages either way; but that way is probably better given that it doesn't introduce an arbitrary (albeit common) character substitution.

Would it be possible to edit the original post on this thread to refer to that way of getting the values? I often find that finding things like this in the forum can be tricky - and if as much as possible is concentrated into the thread that introduces the enhancement it helps to find it later!
That's an awesome solution!

I've tested with a clonable page that I have here, and It works like a charm!

However, there is something i've been thinking about: Could this be used with pages which has a mosaic? How?
Previous 1, 2, 3, 4, 5, 6 Next
55 posts Page 6 of 6
cron