Linux has a great little utility called split, which can take a file and split it into chunks of whatever size you want, eg 100 line chunks.
However, for CSV files etc, each chunk generally needs to have the header row in there. Unfortunately the split command doesn't have an option for that. However with a [...]
Archive: file
Posts Tagged ‘file’
October 27, 2009
1 Comment
September 3, 2009
No Comments
This little PHP function will allow you to import a csv or tab etc delimited text file into a database table. Handy if you need it
PLAIN TEXT
PHP:
function build_table_from_file($tablename, $filepath, $delim="\t") {
db_query("DROP TABLE IF EXISTS $tablename");
$fp=fopen($filepath, 'r');
$headers=false;
while($r=(($delim=='csv')?fgetcsv($fp):fgets($fp))) {
if($delim!='csv'){
[...]
Categories:
Archive by date: