dividing a file into two

Hi ..
I have a file which contains a list of numbers like..

1923,1924,1925,1926,1927,1928,1929,1930,1931,1932,2015,2016,2017,2018,2019,2020,2021,2022,2023,2024,2025,2026,2027,
2028,2029,2030,2031,2032,2115,2116,2117,2118,2119,2120,2121,2122,2123,2124,2125,2126,2127,2128,2129,2130,2131,2132,
2215,2216,2217,2218,2219,2220,2221,2222,2223,2224,2225,2226,2227,2228,2229,2230,2231,2232,2315,2316,2317,2318,2319,
2320,2321,2322,2323,2324,2325,2326,2327,2328,2329,2330,2331,2332,2412,2413,2414,2415,2416,2417,2418,2419,2420,2421,
2422,2423,2424,2425,2426,2427,2428,2429,2430,2431,2432,2512,2513,2514,2515,2516,2517,2518,2519,2520,2521,2522,2523,
2524,2525,2526,2527,2528,2529,2530,2531,2532,2612,2613,2614,2615,2616,2617,2618,2619,2620,2621,2622,2623,2624,2625,
2626,2627,2628,2629,2630,2631,2632,2712,2713,2714,2715,2716,2717,2718,2719,2720,2721,2722,2723,2724,2725,2726,2727,
2728,2729,2730,2731,2732,2733,2810,2811,2812,2813,2814,2815,2816,2817,2818,2819,2820,2821,2822,2823,2824,2825,2826,
2827,2828,2829,2830,2831,2832,2833,2910,2911,2912,2913,2914,2915,2916,2917,2918,2919,2920,2921,2922,2923,2924,2925,
2926,2927,2928,2929,2930,2931,2932,2933,3010,3011,3012,3013,3014,3015,3016,3017,3018,3019,3020,3021,3022,3023,3024,
3025,3026,3027,3028,3029,3030,3031,3032,3033,3034,3035,3036,3037,3110,3111,3112,3113,3114,3115,3116,3117,3118,3119,
3120,3121,3122,3123,3124,3125,3126,3127,3128,3129,3130,3131,3132,3133,3134,3135,3136,3137,3210,3211,3212,3213,3214,
3215,3216,3217,3218,3219,3220,3221,3222,3223,3224,3225,3226,3227,3228,3229,3230,3231,3232,3233,3234,3235,3236,3237,
3310,3311,3312,3313,3314,3315,3316,3317,3318,3319,3320,3321,3322,3323,3324,3325,3326,3327,3328,3329,3330,3331,3332,
3333,3334,3335,3336,3337,

I have to divide the numbers in such a way that, all the numbers less than and equal to xx31 must be outputted to a seperate file, and all the numbers greater than and equal to xx32 must be outputted to a seperate file.

That means I should have the following files as output:

1923,1924,1925,1926,1927,1928,1929,1930,1931,2015,2016,2017,2018,2019,2020,2021,2022,2023,2024,2025,2026,2027,2028,2029,2030,2031,
2115,2116,2117,2118,2119,2120,2121,2122,2123,2124,2125,2126,2127,2128,2129,2130,2131,
2215,2216,2217,2218,2219,2220,2221,2222,2223,2224,2225,2226,2227,2228,2229,2230,2231,
2315,2316,2317,2318,2319,2320,2321,2322,2323,2324,2325,2326,2327,2328,2329,2330,2331,
2412,2413,2414,2415,2416,2417,2418,2419,2420,2421,2422,2423,2424,2425,2426,2427,2428,2429,2430,2431,
2512,2513,2514,2515,2516,2517,2518,2519,2520,2521,2522,2523,2524,2525,2526,2527,2528,2529,2530,2531,
2612,2613,2614,2615,2616,2617,2618,2619,2620,2621,2622,2623,2624,2625,2626,2627,2628,2629,2630,2631,
2712,2713,2714,2715,2716,2717,2718,2719,2720,2721,2722,2723,2724,2725,2726,2727,2728,2729,2730,2731,
2810,2811,2812,2813,2814,2815,2816,2817,2818,2819,2820,2821,2822,2823,2824,2825,2826,2827,2828,2829,2830,2831,
2910,2911,2912,2913,2914,2915,2916,2917,2918,2919,2920,2921,2922,2923,2924,2925,2926,2927,2928,2929,2930,2931,
3010,3011,3012,3013,3014,3015,3016,3017,3018,3019,3020,3021,3022,3023,3024,3025,3026,3027,3028,3029,3030,3031,
3110,3111,3112,3113,3114,3115,3116,3117,3118,3119,3120,3121,3122,3123,3124,3125,3126,3127,3128,3129,3130,3131,
3210,3211,3212,3213,3214,3215,3216,3217,3218,3219,3220,3221,3222,3223,3224,3225,3226,3227,3228,3229,3230,3231,
3310,3311,3312,3313,3314,3315,3316,3317,3318,3319,3320,3321,3322,3323,3324,3325,3326,3327,3328,3329,3330,3331,
3409,3410,3411,3412,3413,3414,3415,3416,3417,3418,3419,3420,3421,3422,3423,3424,3425,3426,3427,3428,3429,3430,3431,
3509,3510,3511,3512,3513,3514,3515,3516,3517,3518,3519,3520,3521,3522,3523,3524,3525,3526,3527,3528,3529,3530,3531,
3609,3610,3611,3612,3613,3614,3615,3616,3617,3618,3619,3620,3621,3622,3623,3624,3625,3626,3627,3628,3629,3630,3631,
3709,3710,3711,3712,3713,3714,3715,3716,3717,3718,3719,3720,3721,3722,3723,3724,3725,3726,3727,3728,3729,3730,3731,
3809,3810,3811,3812,3813,3814,3815,3816,3817,3818,3819,3820,3821,3822,3823,
3909,3910,3911,3912,3913,3914,3915,3916,3917,3918,3919,3920,3921,3922,3923,
4009,4010,4011,4012,4013,4014,4015,4016,4017,4018,4019,4020,4021,4022,4023,
4109,4110,4111,4112,4113,4114,4115,4116,4117,4118,4119,4120,4121,4122,4123,
4209,4210,4211,4212,4213,4214,4215,4216,4217,4218,4219,4220,4221,4222,4223,
4309,4310,4311,4312,4313,4314,4315,4316,4317,4318,4319,4320,4321,4322,4323

and

1932,2032,2132,2232,2332,2432,2532,2632,2732,2733,2832,2833,2932,2933,
3032,3033,3034,3035,3036,3037,3132,3133,3134,3135,3136,3137,
3232,3233,3234,3235,3236,3237,3332,3333,3334,3335,3336,3337,
3432,3433,3434,3435,3436,3437,3532,3533,3534,3535,3536,3537,
3632,3633,3634,3635,3636,3637,3732,3733,3734,3735

Can anyone help?

Thankx
Jazz

If that is all that you need consider awk:

awk -F"," '{
    for(i=1;i<=NF;i++){
        if(substr($i,3,2)>31 ) {print $i > "bigger_file.dat"}
        else { print $i > "smaller_file.dat"}
    }

}' inputfilename

Thankx a lot!!