Jump to content

"Empty" rows in a table help...


osyrys14

Recommended Posts

I have a DB that I've been working on importing data to from text files.  The data imports fine, but if its a report that has no data (or just a header) it inserts what seems to be a blank row.  usually, I can delete these with a simple SELECT * FROM table WHERE name=''; to be sure, and DELETE FROM table WHERE name='';, neither of which is returning any results.

 

Also, is there a way to check for this on the import so I won't have the empty rows to deal with in the future.  

 

Thanks so much for any help that anyone can provide.

 

Link to comment
Share on other sites

My apologies, I worded that wrong.  The rows appear to be empty, but using the SQL commands above do not find or delete them.  The text files are aparently filled with something that is showing as blank, but not truly empty.  And it's not on an insert statement, they are hourly files we import once a day for querying later for usage statistics.  Like an activity log.

Link to comment
Share on other sites

And it's not on an insert statement, they are hourly files we import once a day for querying later for usage statistics.

 

And you are you processing those import files to create records in the database? If you are using something like MySQL "LOAD DATA" on a file that is not "clean" then you are going to end up with garbage. I'm guessing the same thing as davidannis. You should pre-process the file before creating the records to remove any invalid data.

Link to comment
Share on other sites

I've recently tried using this statement, since I found another column in the row that DOES have data that I don't need, so I try this... 

 

DELETE FROM cdr WHERE tablename LIKE '%billing_file%';

 

Still no results, when I know billing_file is in that field, but that's just the start of the name, so I can't use tablename = 'billing_file'

Link to comment
Share on other sites

That is for YOU to decide. I have no clue about the source of the data you are using, the requirements of the data to be stored, etc. etc. But, based upon your statements, you are getting records that should not exist. So you need to clean it up. One way would be to process the data into individual records for the database - removing/skipping any that should be considered "invalid", then running the query to insert all the valid records

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.