We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Plugin: CSVee

Development and Programming

Ryan M.'s avatar
Ryan M.
1,511 posts
16 years ago
Ryan M.'s avatar Ryan M.

Looks like that site is on a PHP 4.4.8/mysql 4.1.22 server.

Just gave that query one more try through Navicat, and the column I’m trying to format returns “[Null]”.

SELECT entry_date, 
date_format(entry_date, '%c/%e/%Y') AS formatted_date, 
email 
FROM exp_freeform_entries 
ORDER BY entry_date DESC

resulted in:

1225305383  [Null]  [email protected]
1225301519  [Null]  [email protected]
1218244116  [Null]  [email protected]
1217824199  [Null]  [email protected]

My other thought was to target the entry_date field and use PHP date() to format that field right in the plugin, but it doesn’t seem like should have to go there.

       
Daniel Walton's avatar
Daniel Walton
553 posts
16 years ago
Daniel Walton's avatar Daniel Walton

Yes of course, it’s a unix timestamp :|

try

SELECT entry_date,
date_format(from_unixtime(entry_date), '%c/%e/%Y') AS formatted_date,
email
FROM exp_freeform_entries
ORDER BY entry_date DESC
       
Ryan M.'s avatar
Ryan M.
1,511 posts
16 years ago
Ryan M.'s avatar Ryan M.

Daniel, thank you - that last query worked perfectly.

       
Brian M.'s avatar
Brian M.
529 posts
16 years ago
Brian M.'s avatar Brian M.

Daniel - I have a SQL statement that will return results when run directly against the DB (in phpMyAdmin), but when I use your plug-in, nothing is downloaded. This is the only thing on the template, so it’s something in your plug-in it would seem? I can’t figure it out - I’ve been looking at the plug-in and I can’t see any reason this wouldn’t work:

{exp:csvee query="SELECT
                 company_uid,
                FROM_UNIXTIME(entry_date, '%m/%d/%Y') AS `date`,
                company,
                 last_name,
                first_name,
                title,
                address,
                address_2,
                city,
                state,
                county,
                zip,
                phone,
                fax,
                email,
                url,
                contact_control,
                business_description,
                employees,
                category,
                member_discount,
                options,
                membership_level,
                REPLACE(donation, 'Other:', '') AS donation,
                donation_amount,
                'CC' AS `payment type`,
                approval_num,
                tags,
                member_to_member_communication,
                password,
                subscription_id AS `notes`
                
                FROM exp_freeform_entries 
                WHERE form_name = 'update_info_form'
                ORDER BY entry_date
                DESC"
                
filename="update_submissions.csv"}

I have two other export templates that use that exact same code and just changes the “WHERE” clause, and they both work as well. Any thoughts? Could there be something in the results themselves that could be somehow tripping up the generation of the CSV?

Thanks…

       
Brian M.'s avatar
Brian M.
529 posts
16 years ago
Brian M.'s avatar Brian M.

Edit - I’m still trying to track down exactly what’s going on, but it probably isn’t your extension. There’s a few other weird things happening

It does bring up another thing I was going to say though. I’ve used this plug-in a few times and it’s great. A feature I’d find really useful would be a debug option - if your SQL throws an error or something doesn’t work, you could get the SQL statement itself and the MySQL error response. Just a thought - I tend to need to debug my SQL statements and have to use another tool to see what actually happens if it’s not a good query.

       
Daniel Walton's avatar
Daniel Walton
553 posts
16 years ago
Daniel Walton's avatar Daniel Walton

Does this solve it?

       
Brian M.'s avatar
Brian M.
529 posts
16 years ago
Brian M.'s avatar Brian M.

That’s got it - thanks! What was happening?

       
Daniel Walton's avatar
Daniel Walton
553 posts
16 years ago
Daniel Walton's avatar Daniel Walton

Danger Will Robinson!

       
Brian M.'s avatar
Brian M.
529 posts
16 years ago
Brian M.'s avatar Brian M.

Daniel - something else happens during CSV formation that was causing a Filemaker consultant to pull her hair out. It adds an extra line at the beginning and end of the CSV. I modified (just for myself) the plug-in so it didn’t include a carrage return on the end, but didn’t quickly see where the beginning extra line was coming from (and it seemed like it wasn’t always there?).

Just thought I would mention it (I’m sure you’re just waiting around for things to do to this plug-in!)

       
Firebrand Media's avatar
Firebrand Media
57 posts
16 years ago
Firebrand Media's avatar Firebrand Media

I have the following SQL Query which is pulling information from the database (the simple commerce module table specifically) and I need to export it to a CSV file. Currently it generates a text web page.

{exp:query sql="SELECT c.item_id, purchase_date, item_cost, paypal_details, entry_id, txn_id FROM
exp_simple_commerce_purchases c, exp_simple_commerce_items e
WHERE e.item_id = c.item_id"}
{exp:weblog:entries weblog="misc_content" entry_id="{entry_id}" dynamic="off"}
<strong>{title}</strong>

{exp:paypal_details details="first_name"}{paypal_details}{/exp:paypal_details} {exp:paypal_details details="last_name"}{paypal_details}{/exp:paypal_details}

{exp:paypal_details details="address_street"}{paypal_details}{/exp:paypal_details}

{exp:paypal_details details="address_city"}{paypal_details}{/exp:paypal_details} {exp:paypal_details details="address_state"}{paypal_details}{/exp:paypal_details} {exp:paypal_details details="address_zip"}{paypal_details}{/exp:paypal_details} {exp:paypal_details details="address_country"}{paypal_details}{/exp:paypal_details}

{/exp:weblog:entries}
Date of Sale: <strong>{purchase_date format="%d %M %Y"}</strong>
<hr >
{if no_results}
They have made no purchases
{/if}
{/exp:query}

Is this possible with the CSVee plugin? I used CSVee to pull the data itself - which was easy, great plugin - but I couldn’t figure out how to unserialize the data to extract only what I need.

Any suggestions or guidance would be great!

Thanks, Brad Hopkins

       
Daniel Walton's avatar
Daniel Walton
553 posts
16 years ago
Daniel Walton's avatar Daniel Walton

Hey Brad - unfortuntely the plugin is incapable. Not through design but through context, Im sure with a little tweaking you could get this working 😊

       
Firebrand Media's avatar
Firebrand Media
57 posts
16 years ago
Firebrand Media's avatar Firebrand Media

Thanks for the response. I was able to make this work with another plugin.

Thanks, Brad Hopkins

       
Blue Flavor's avatar
Blue Flavor
36 posts
16 years ago
Blue Flavor's avatar Blue Flavor

I’m using this plugin to export a CSV of some weblog data. It works great, minus one problem, it doesn’t seem to want to keep the characters I have in front of some of my strings. In my case it’s this one: ± in front of numbers. It seems to just output the numbers.

       
Daniel Walton's avatar
Daniel Walton
553 posts
16 years ago
Daniel Walton's avatar Daniel Walton
I’m using this plugin to export a CSV of some weblog data. It works great, minus one problem, it doesn’t seem to want to keep the characters I have in front of some of my strings. In my case it’s this one: ± in front of numbers. It seems to just output the numbers.

Sure that isn’t just excel being… well, excel? (opened the file in notepad to verify?)

       
Blue Flavor's avatar
Blue Flavor
36 posts
16 years ago
Blue Flavor's avatar Blue Flavor

This was from opening it in Textmate, opening it in Numbers.

Interestingly enough, I solved the problem by using php and setlocale to UTF-8.

Really. Badass. Plugin. Thank you for it. Saved me a crap-ton of work.

Cheers, Kenny

       
First 2 3 4 5 6 Last

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.