https://huggingface.co/datasets/fivetech/forums_dbf/tree/main
forums_csv.prg
- Code: Select all Expand view
- #include "FiveWin.ch"
request dbfcdx
function Main()
local cPostsCSV := "topic,text" + Chr( 10 )
USE posts VIA "dbfcdx"
INDEX ON posts->topic + posts->date + posts->time + posts->forum TO subject
GO TOP
while ! EoF()
cPostsCSV += StrTran( StrTran( StrTran( StrToUtf8( RTrim( posts->topic ) ), ["], [""] ), CRLF, "" ), ",", "" ) + ',"' + ;
StrTran( StrTran( StrToUtf8( RTrim( posts->text ) ), ["], [""] ), CRLF, "" ) + '"' + Chr( 10 )
SKIP
end
hb_memoWrit( "forums.csv", cPostsCSV )
return nil
#pragma BEGINDUMP
#include <windows.h>
#include <hbapi.h>
HB_FUNC( STRTOUTF8 )
{
int iLength1;
int iLength2;
LPWSTR szWideText;
char * szDest;
iLength1 = MultiByteToWideChar( CP_ACP, 0, hb_parc( 1 ), hb_parclen( 1 ), NULL, 0 );
szWideText = ( LPWSTR ) hb_xgrab( ( iLength1 + 1 ) * 2 );
MultiByteToWideChar( CP_ACP, 0, hb_parc( 1 ), hb_parclen( 1 ), szWideText, iLength1 );
szWideText[ iLength1 ] = NULL;
iLength2 = WideCharToMultiByte( CP_UTF8, 0, szWideText, iLength1, NULL, 0, NULL, NULL );
szDest = ( char * ) hb_xgrab( iLength2 + 1 );
WideCharToMultiByte( CP_UTF8, 0, szWideText, iLength1, szDest, iLength2, NULL, NULL );
hb_xfree( ( void * ) szWideText );
szDest[ iLength2 ] = NULL;
hb_retc( szDest );
hb_xfree( ( void * ) szDest );
}
#pragma ENDDUMP
Resulting forums.csv file:
https://huggingface.co/datasets/fivetech/forums_csv/tree/main