Page 2 of 4 FirstFirst 1234 LastLast
Results 11 to 20 of 31

Thread: Export Data to CSV (Using PHP)

  1. #11
    Join Date
    Aug 2005
    Posts
    174
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default

    i dont know what regex is, but i guess u are tryin 2 select only the data in within the body tags?!

  2. #12
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Right. Trying, and still failing. Why won't PHP allow me a character class?!
    Mike, help!
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #13
    Join Date
    Aug 2005
    Posts
    174
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default

    you had any luck with this twey?

    I cant think of any alternative ways of doin this either!

  4. #14
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    I'm a lot less knowledgable than you guys, but might I suggest that you're working too hard?
    It's not like you need to do this more than once.

    First... cut/paste what you see, not the code, into a text file, or .htm file... whatever.
    Then use that. And you've got it so much easier.

    From there, just have it go through character by character, splitting the data at a |. This is what you're doing, but should be a lot easier when it's more in your control.

    Now... I'm not sure what a .csv file is, so I don't know if I might be suggesting something that would make it harder to export to that, but I hope not.

    Hope this helps.

  5. #15
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    you had any luck with this twey?
    I haven't, no. It's beginning to bug me.
    It's not like you need to do this more than once.
    It needs to be kept updated. That's the point.
    I'm not sure what a .csv file is
    CSV stands for Comma-Seperated Values. It's a method of storing data, seperated by commas (or, less specifically, any ASCII character; the pipe symbol [|] in this case).
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  6. #16
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Hmmm... ok. Well.... isn't there an easy way in php to do, basically, cutting and pasting of what you'd see?
    And .csv works how? Just out of curiosity... like.. how does it differ from .txt?

  7. #17
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    isn't there an easy way in php to do, basically, cutting and pasting of what you'd see?
    Yes. That's what I'm trying to do.
    Just out of curiosity... like.. how does it differ from .txt?
    It doesn't. You're evidently a Windows user -- used to your OS determining how things are treated by their file extension. File extensions are just a convenient method of seeing what type of data the file contains at a glance. They don't have any actual import on the content of the file; for example, I could name an executable .txt, or a text file .so, and it wouldn't actually change the content of the file (although Windows would probably refuse to handle it until I changed it back).
    The only difference between a CSV-structured text file and a non-structured text file is how it will be handled. This is the same as the difference between a CSV file and an HTML file, or any two filetypes you'd care to name, in fact.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  8. #18
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    I'm not on linux, but I'm on a mac and a pc right now... (I do video editing on my mac, and internet and such on my pc.. they're right next to each other).

    I know how file extensions work, but I wasn't sure if .csv was a different format in the way that data would be stored within it.
    Also... yeah... you can rename files to some extent on macs and it'll still read them. Windows is more touchy. You can also do things like renaming the filetype to get around free webhosts that block filetypes. ^_^

    So... yeah... go on. Just curious. got it now, thanks.

  9. #19
    Join Date
    Dec 2004
    Location
    UK
    Posts
    2,358
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by Twey
    preg_match('<body\b[^>]*>(.*?)<\/body>', $inc, $s);
    Your problem here is a lack of delimiters. The regular expression parser will be treating the first less-than character as a delimiter, and will be looking for a greater-than character to mark the end of the pattern (and the start of the flags).

    I'm used to using slashes to delimit patterns, as that's how ECMAScript regular expression literals are formatted.

    PHP Code:
    preg_match('/<body\b[^>]*>(.*?)<\/body>/'$inc$s); 
    By the way, I haven't tested this. I only just happened to glance at the thread.

    Mike

  10. #20
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Mike saves the day again.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •