Advertisement
Guest User

csv to sql

a guest
Aug 17th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. char id[256];
  4. char nome[256];
  5. char username[256];
  6.  
  7. int main()
  8. {
  9. while(scanf("%[^,],", id)!=EOF)
  10. {
  11.  
  12. if(scanf("\"%[^\"]\",", nome) == 0)
  13. scanf("%[^,],", nome);
  14.  
  15. if(scanf("\"%[^\"]\"\n", username) == 0)
  16. scanf("%[^,\n]\n", username);
  17.  
  18. printf("insert into test_users (id, nome, username) values ('%s', '%s', '%s');\n", id, nome, username);
  19. }
  20.  
  21. return 0;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement