dbf2txt.sh

http://www.awanx.com/
回覆文章
yehlu
Site Admin
文章: 3245
註冊時間: 2004-04-15 17:20:21
來自: CodeCharge Support Engineer

dbf2txt.sh

文章 yehlu »

代碼: 選擇全部

#!/bin/bash
#$search_dir = '/home/backup/ntfs1/htpos/*.DBF';
for entry in "/home/backup/ntfs1/htpos"/*DBF
do
  echo "$entry"
  fname=`basename  $entry`
  echo $fname".TXT"
  php dbase01.php $entry > $fname".TXT"
done
yehlu
Site Admin
文章: 3245
註冊時間: 2004-04-15 17:20:21
來自: CodeCharge Support Engineer

dbase01.php

文章 yehlu »

代碼: 選擇全部

<?php
$db = dbase_open($argv[1], 0);

if ($db) {
  $record_numbers = dbase_numrecords($db);
  for ($i = 1; $i <= $record_numbers; $i++) {
      $row = dbase_get_record_with_names($db, $i);
      if($i == 1){
          echo '{split=,}{fields=';
	  foreach($row as $key => $value){
              echo iconv('Big5','UTF-8',$key).',';
          }
	  echo "}\n";
      }
      if($row['deleted']==0){
      foreach($row as $key => $value){
          echo iconv('Big5','UTF-8//ignore',trim(preg_replace('/\s\s+/', ' ',$value))).",";
      }
      echo "\n";
      }
  }
}
回覆文章

回到「E3進銷存」